StringMap: Add decrement operations to iterator.

This commit is contained in:
Peter Johnson
2018-05-04 20:19:55 -07:00
parent cff475c1fc
commit dd4230d743

View File

@@ -450,11 +450,24 @@ public:
StringMapConstIterator tmp = *this; ++*this; return tmp;
}
inline StringMapConstIterator& operator--() { // Predecrement
--Ptr;
ReversePastEmptyBuckets();
return *this;
}
StringMapConstIterator operator--(int) { // Postdecrement
StringMapConstIterator tmp = *this; --*this; return tmp;
}
private:
void AdvancePastEmptyBuckets() {
while (*Ptr == nullptr || *Ptr == StringMapImpl::getTombstoneVal())
++Ptr;
}
void ReversePastEmptyBuckets() {
while (*Ptr == nullptr || *Ptr == StringMapImpl::getTombstoneVal())
--Ptr;
}
};
template<typename ValueTy>