Added TimeRange.trim() method
This commit is contained in:
parent
734d06ad38
commit
bd1f8226ec
|
@ -58,6 +58,11 @@ void TimeRange::shrink(time_type value) {
|
||||||
grow(-value);
|
grow(-value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimeRange::trim(const TimeRange& limits) {
|
||||||
|
TimeRange newRange(std::max(start, limits.start), std::min(end, limits.end));
|
||||||
|
resize(newRange);
|
||||||
|
}
|
||||||
|
|
||||||
bool TimeRange::operator==(const TimeRange& rhs) const {
|
bool TimeRange::operator==(const TimeRange& rhs) const {
|
||||||
return start == rhs.start && end == rhs.end;
|
return start == rhs.start && end == rhs.end;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
void shift(time_type offset);
|
void shift(time_type offset);
|
||||||
void grow(time_type value);
|
void grow(time_type value);
|
||||||
void shrink(time_type value);
|
void shrink(time_type value);
|
||||||
|
void trim(const TimeRange& limits);
|
||||||
|
|
||||||
bool operator==(const TimeRange& rhs) const;
|
bool operator==(const TimeRange& rhs) const;
|
||||||
bool operator!=(const TimeRange& rhs) const;
|
bool operator!=(const TimeRange& rhs) const;
|
||||||
|
|
Loading…
Reference in New Issue