22 #ifndef COMMON_MULTIMAP_H 23 #define COMMON_MULTIMAP_H 25 #include "common/util.h" 26 #include "common/rb_tree.h" 33 template<
class Key,
class Val,
class CompFunc = Common::Less<Key> >
53 return _items.
begin();
67 return _items.
begin();
73 const_iterator
end()
const {
89 iterator upper_bound(
const Key &key) {
96 iterator
find(
const Key &theKey) {
98 if (it != this->
end() && compareEqual(it->first, theKey))
103 const_iterator
find(
const Key &theKey)
const {
104 const_iterator it = _items.
lowerBound(theKey);
105 if (it != this->
end() && compareEqual(it->first, theKey))
114 return _items.
erase(it);
117 iterator
erase(iterator first, iterator last) {
118 return _items.
erase(first, last);
121 iterator
erase(
const Key &theKey) {
122 const iterator first =
find(theKey);
123 iterator last = first;
124 while (last != this->
end() && compareEqual(last->first, theKey))
126 return _items.
erase(first, last);
130 return _items.
insert(val);
137 return _items.
size();
149 for (iterator it = this->
begin(); it != this->
end(); ++it) {
150 if (compareEqual(it->first, theKey))
157 bool compareEqual(
const Key &a,
const Key &b) {
158 return !_comp(a, b) && !_comp(b, a);
const_iterator lower_bound(const Key &key) const
Definition: multimap.h:81
void clear()
Definition: multimap.h:45
size_t size() const
Definition: multimap.h:136
iterator erase(iterator it)
Definition: multimap.h:113
const_iterator begin() const
Definition: multimap.h:66
bool isEmpty() const
Definition: rb_tree.h:336
iterator end()
Definition: multimap.h:59
BasicIterator upperBound(const Key &key)
Definition: rb_tree.h:217
BasicIterator lowerBound(const Key &key)
Definition: rb_tree.h:181
BasicIterator insert(const ValueType &val)
Definition: rb_tree.h:302
Definition: multimap.h:34
size_t count(const Key &theKey)
Definition: multimap.h:147
Definition: algorithm.h:29
Iterator< const Pair< Key, Val > &, const Pair< Key, Val > *> ConstIterator
Definition: rb_tree.h:123
iterator find(const Key &theKey)
Definition: multimap.h:96
Iterator< Pair< Key, Val > &, Pair< Key, Val > *> BasicIterator
Definition: rb_tree.h:122
const_iterator end() const
Definition: multimap.h:73
iterator begin()
Definition: multimap.h:52
BasicIterator erase(BasicIterator it)
Definition: rb_tree.h:250
void clear()
Definition: rb_tree.h:158
size_t size() const
Definition: rb_tree.h:327
BasicIterator begin()
Definition: rb_tree.h:166
BasicIterator end()
Definition: rb_tree.h:172