59 void add(
double begin,
double end, T value) {
65 myValues[begin] = std::make_pair(
true, value);
66 myValues[end] = std::make_pair(
false, value);
70 typename TimedValueMap::iterator endIt =
myValues.find(end);
73 myValues[begin] = std::make_pair(
true, value);
81 myValues[begin] = std::make_pair(
true, value);
95 typename TimedValueMap::const_iterator it =
myValues.upper_bound(time);
98 return it->second.second;
112 typename TimedValueMap::const_iterator afterIt =
myValues.upper_bound(time);
117 return afterIt->second.first;
131 typename TimedValueMap::const_iterator afterLow =
myValues.upper_bound(low);
132 typename TimedValueMap::const_iterator afterHigh =
myValues.upper_bound(high);
134 if (afterLow == afterHigh) {
135 return afterLow->first;
145 void fillGaps(T value,
bool extendOverBoundaries =
false) {
146 for (
typename TimedValueMap::iterator it =
myValues.begin(); it !=
myValues.end(); ++it) {
147 if (!it->second.first) {
148 it->second.second = value;
151 if (extendOverBoundaries && !
myValues.empty()) {
152 typename TimedValueMap::iterator it = --
myValues.end();
153 if (!it->second.first) {
156 value =
myValues.begin()->second.second;
158 myValues[-1] = std::make_pair(
false, value);
double getSplitTime(double low, double high) const
Returns the time point at which the value changes.
bool describesTime(double time) const
Returns whether a value for the given time is known.
T getValue(double time) const
Returns the value for the given time.
~ValueTimeLine()
Destructor.
void fillGaps(T value, bool extendOverBoundaries=false)
Sets a default value for all unset intervals.
TimedValueMap myValues
The list of time periods (with values)
void add(double begin, double end, T value)
Adds a value for a time interval into the container.
ValueTimeLine()
Constructor.
std::pair< bool, T > ValidValue
Value of time line, indicating validity.
std::map< double, ValidValue > TimedValueMap
Sorted map from start of intervals to values.