s/properties/propertyValues/

This list stores different values for the same property, but the
property itself remains the same.
This commit is contained in:
Bruno de Oliveira Abinader
2015-07-13 03:15:14 +03:00
parent 7023ea061c
commit 7d8b4dc6c0
3 changed files with 11 additions and 12 deletions

View File

@@ -10,15 +10,15 @@ AppliedClassProperty::AppliedClassProperty(ClassID class_id, TimePoint begin_, T
// Returns the ID of the most recent
ClassID AppliedClassProperties::mostRecent() const {
return properties.size() ? properties.back().name : ClassID::Fallback;
return propertyValues.empty() ? ClassID::Fallback : propertyValues.back().name;
}
void AppliedClassProperties::add(ClassID class_id, TimePoint begin, TimePoint end, const PropertyValue &value) {
properties.emplace_back(class_id, begin, end, value);
propertyValues.emplace_back(class_id, begin, end, value);
}
bool AppliedClassProperties::hasTransitions() const {
return properties.size() > 1;
return propertyValues.size() > 1;
}
// Erase all items in the property list that are before a completed transition.
@@ -26,19 +26,19 @@ bool AppliedClassProperties::hasTransitions() const {
void AppliedClassProperties::cleanup(TimePoint now) {
// Iterate backwards, but without using the rbegin/rend interface since we need forward
// iterators to use .erase().
for (auto it = properties.end(), begin = properties.begin(); it != begin;) {
for (auto it = propertyValues.end(), begin = propertyValues.begin(); it != begin;) {
// If the property is finished, break iteration and delete all remaining items.
if ((--it)->end <= now) {
// Removes all items that precede the current iterator, but *not* the element currently
// pointed to by the iterator. This preserves the last completed transition as the
// first element in the property list.
properties.erase(begin, it);
propertyValues.erase(begin, it);
// Also erase the pivot element if it's a fallback value. This means we can remove the
// entire applied properties object as well, because we already have the fallback
// value set as the default.
if (it->name == ClassID::Fallback) {
properties.erase(it);
propertyValues.erase(it);
}
break;
}
@@ -46,7 +46,7 @@ void AppliedClassProperties::cleanup(TimePoint now) {
}
bool AppliedClassProperties::empty() const {
return properties.empty();
return propertyValues.empty();
}
}