Added TimeRange.trim() method

This commit is contained in:
Daniel Wolf 2016-08-11 10:16:50 +02:00
parent 734d06ad38
commit bd1f8226ec
2 changed files with 6 additions and 0 deletions

View File

@ -58,6 +58,11 @@ void TimeRange::shrink(time_type 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 {
return start == rhs.start && end == rhs.end;
}

View File

@ -24,6 +24,7 @@ public:
void shift(time_type offset);
void grow(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;