31 #ifndef COMMON_STD_MAP_H 32 #define COMMON_STD_MAP_H 34 #include "common/hashmap.h" 35 #include "common/std/utility.h" 39 template<
class Key,
class Val,
class CompFunc = Common::Less<Key> >
63 return _items.
begin();
77 return _items.
begin();
83 const_iterator
end()
const {
92 const_iterator first = this->
begin();
94 int count_ = _items.
size(), step;
101 if (_comp(it->_key, theKey)) {
113 iterator first = this->
begin();
115 int count_ = _items.
size(), step;
122 if (_comp(it->_key, theKey)) {
136 iterator
find(
const Key &theKey) {
139 if (it != this->
end() && it->_key == theKey)
144 const_iterator
find(
const Key &theKey)
const {
147 if (it != this->
end() && it->_key == theKey)
157 if (it == this->
end() || it->_key != theKey) {
158 size_t idx = it - this->
begin();
160 _items[idx]._key = theKey;
161 return _items[idx]._value;
163 return _items[it - this->
begin()]._value;
177 iterator
erase(
const Key &theKey) {
185 return _items.
size();
193 for (iterator it = this->
begin(); it != this->
end(); ++it) {
194 if (it->_key == theKey)
202 template<
class Key,
class Val,
class HashFunc = Common::Hash<Key>,
203 class EqualFunc = Common::EqualTo<Key> >
208 if (this->contains(elem.first))
216 void reserve(
size_t size) {
iterator begin()
Definition: map.h:62
const_iterator end() const
Definition: map.h:83
const_iterator begin() const
Definition: map.h:76
const_iterator lower_bound(const Key &theKey) const
Definition: map.h:91
void insert_at(size_type idx, const T &element)
Definition: array.h:241
void clear()
Definition: map.h:55
size_t count(const Key &theKey)
Definition: map.h:191
void clear()
Definition: array.h:320
iterator end()
Definition: array.h:379
iterator begin()
Definition: array.h:374
T * iterator
Definition: array.h:54
Val & operator[](const Key &theKey)
Definition: map.h:155
size_t size() const
Definition: map.h:184
const T * const_iterator
Definition: array.h:55
size_type size() const
Definition: array.h:315
T remove_at(size_type idx)
Definition: array.h:260
iterator erase(iterator it)
Definition: map.h:170
iterator end()
Definition: map.h:69
Definition: algorithm.h:37
iterator find(const Key &theKey)
Definition: map.h:136