🅵
Size: a a a
r
r
🅵
S
r
🅵
r
🅵
final List<HTTPPeriod> _list;
void mergeIntersections() {
final List<HTTPPeriod> _tmp = <HTTPPeriod>[];
for (HTTPPeriod period in this._list) {
final int index = _tmp.indexWhere((HTTPPeriod other) => period.isOverlapped(other));
if (index >= 0) {
final HTTPPeriod other = _tmp[index];
_tmp[index] = HTTPPeriod(
start: period.start.compareTo(other.start) < 0 ? period.start : other.start,
end: period.end.compareTo(other.end) > 0 ? period.end : other.end
);
} else {
_tmp.add(period);
}
}
this._list
..clear()
..addAll(_tmp)
..sort();
}
bool isOverlapped(HTTPPeriod other) =>
this.start.compareTo(other.start) >= 0
&& this.start.compareTo(other.end) <= 0
||
this.end.compareTo(other.start) >= 0
&& this.end.compareTo(other.end) <= 0;
🅵
final List<HTTPPeriod> _list;
void mergeIntersections() {
final List<HTTPPeriod> _tmp = <HTTPPeriod>[];
for (HTTPPeriod period in this._list) {
final int index = _tmp.indexWhere((HTTPPeriod other) => period.isOverlapped(other));
if (index >= 0) {
final HTTPPeriod other = _tmp[index];
_tmp[index] = HTTPPeriod(
start: period.start.compareTo(other.start) < 0 ? period.start : other.start,
end: period.end.compareTo(other.end) > 0 ? period.end : other.end
);
} else {
_tmp.add(period);
}
}
this._list
..clear()
..addAll(_tmp)
..sort();
}
bool isOverlapped(HTTPPeriod other) =>
this.start.compareTo(other.start) >= 0
&& this.start.compareTo(other.end) <= 0
||
this.end.compareTo(other.start) >= 0
&& this.end.compareTo(other.end) <= 0;
r
🅵
🅵
ВЫБРАТЬ РАЗЛИЧНЫЕ
Край.От
ПОМЕСТИТЬ ЛевыеКрая
ИЗ
Интервалы КАК Край
ЛЕВОЕ СОЕДИНЕНИЕ Интервалы КАК Интервалы
ПО (Интервалы.От < Край.От)
И Край.От <= Интервалы.До
ГДЕ
Интервалы.От ЕСТЬ NULL
;
////////////////////////////////////////////////////////////////////////////////
ВЫБРАТЬ РАЗЛИЧНЫЕ
Край.До
ПОМЕСТИТЬ ПравыеКрая
ИЗ
Интервалы КАК Край
ЛЕВОЕ СОЕДИНЕНИЕ Интервалы КАК Интервалы
ПО (Интервалы.От <= Край.До)
И Край.До < Интервалы.До
ГДЕ
Интервалы.От ЕСТЬ NULL
;
////////////////////////////////////////////////////////////////////////////////
ВЫБРАТЬ
ЛевыеКрая.От,
МИНИМУМ(ПравыеКрая.До) КАК До
ИЗ
ЛевыеКрая КАК ЛевыеКрая
ВНУТРЕННЕЕ СОЕДИНЕНИЕ ПравыеКрая КАК ПравыеКрая
ПО ЛевыеКрая.От <= ПравыеКрая.До
СГРУППИРОВАТЬ ПО
ЛевыеКрая.От