22 #ifndef ValueTimeLine_h 23 #define ValueTimeLine_h 75 myValues[begin] = std::make_pair(
true, value);
76 myValues[end] = std::make_pair(
false, value);
80 typename TimedValueMap::iterator endIt =
myValues.find(end);
83 myValues[begin] = std::make_pair(
true, value);
91 myValues[begin] = std::make_pair(
true, value);
105 typename TimedValueMap::const_iterator it =
myValues.upper_bound(time);
108 return it->second.second;
122 typename TimedValueMap::const_iterator afterIt =
myValues.upper_bound(time);
127 return afterIt->second.first;
141 typename TimedValueMap::const_iterator afterLow =
myValues.upper_bound(low);
142 typename TimedValueMap::const_iterator afterHigh =
myValues.upper_bound(high);
144 if (afterLow == afterHigh) {
145 return afterLow->first;
155 void fillGaps(T value,
bool extendOverBoundaries =
false) {
156 for (
typename TimedValueMap::iterator it =
myValues.begin(); it !=
myValues.end(); ++it) {
157 if (!it->second.first) {
158 it->second.second = value;
161 if (extendOverBoundaries && !
myValues.empty()) {
162 typename TimedValueMap::iterator it = --
myValues.end();
163 if (!it->second.first) {
166 value =
myValues.begin()->second.second;
168 myValues[-1] = std::make_pair(
false, value);
void fillGaps(T value, bool extendOverBoundaries=false)
Sets a default value for all unset intervals.
SUMOReal getSplitTime(SUMOReal low, SUMOReal high) const
Returns the time point at which the value changes.
~ValueTimeLine()
Destructor.
void add(SUMOReal begin, SUMOReal end, T value)
Adds a value for a time interval into the container.
bool describesTime(SUMOReal time) const
Returns whether a value for the given time is known.
std::pair< bool, SUMOReal > ValidValue
Value of time line, indicating validity.
T getValue(SUMOReal time) const
Returns the value for the given time.
std::map< SUMOReal, ValidValue > TimedValueMap
Sorted map from start of intervals to values.
TimedValueMap myValues
The list of time periods (with values)
ValueTimeLine()
Constructor.