Added time manipulation functions to TimeRange and Timeline
This commit is contained in:
parent
895b942df3
commit
baf2423b27
|
@ -32,6 +32,20 @@ void TimeRange::resize(time_type start, time_type end) {
|
||||||
resize(TimeRange(start, end));
|
resize(TimeRange(start, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimeRange::shift(time_type offset) {
|
||||||
|
start += offset;
|
||||||
|
end += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimeRange::grow(time_type value) {
|
||||||
|
start -= value;
|
||||||
|
end += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TimeRange::shrink(time_type value) {
|
||||||
|
grow(-value);
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ public:
|
||||||
|
|
||||||
void resize(const TimeRange& newRange);
|
void resize(const TimeRange& newRange);
|
||||||
void resize(time_type start, time_type end);
|
void resize(time_type start, time_type end);
|
||||||
|
void shift(time_type offset);
|
||||||
|
void grow(time_type value);
|
||||||
|
void shrink(time_type value);
|
||||||
|
|
||||||
bool operator==(const TimeRange& rhs) const;
|
bool operator==(const TimeRange& rhs) const;
|
||||||
bool operator!=(const TimeRange& rhs) const;
|
bool operator!=(const TimeRange& rhs) const;
|
||||||
|
|
|
@ -191,6 +191,18 @@ public:
|
||||||
return reference(*this, time);
|
return reference(*this, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void shift(time_type offset) {
|
||||||
|
if (offset == time_type::zero()) return;
|
||||||
|
|
||||||
|
range.shift(offset);
|
||||||
|
set_type newElements;
|
||||||
|
for (Timed<T> element : elements) {
|
||||||
|
element.shift(offset);
|
||||||
|
newElements.insert(element);
|
||||||
|
}
|
||||||
|
elements = std::move(newElements);
|
||||||
|
}
|
||||||
|
|
||||||
Timeline(const Timeline&) = default;
|
Timeline(const Timeline&) = default;
|
||||||
Timeline(Timeline&&) = default;
|
Timeline(Timeline&&) = default;
|
||||||
Timeline& operator=(const Timeline&) = default;
|
Timeline& operator=(const Timeline&) = default;
|
||||||
|
|
Loading…
Reference in New Issue