6 #ifndef ctrlplane_index_map_h
7 #define ctrlplane_index_map_h
18 template <
typename KeyType,
typename ValueType,
19 typename BitsetType =
BitSet>
23 typedef std::map<KeyType, ValueType *>
MapType;
36 typename MapType::const_iterator loc =
map_.find(key);
37 if (loc !=
map_.end()) {
44 if (
bits_.test(index))
52 std::pair<typename MapType::iterator, bool> result =
53 map_.insert(std::make_pair(key, value));
59 bit =
bits_.find_first_clear();
70 void Remove(
const KeyType &key,
int index,
bool clear_bit =
true) {
71 typename MapType::iterator loc =
map_.find(key);
72 assert(loc !=
map_.end());
73 assert(loc->second ==
values_[index]);
84 for (int64_t i =
values_.size() - 1; i >= 0; i--) {
96 value->set_index(
Insert(key, value));
116 return map_.lower_bound(key);
121 return map_.lower_bound(key);
MapType::iterator iterator
ValueType * At(int index) const
DISALLOW_COPY_AND_ASSIGN(IndexMap)
std::vector< ValueType * > VectorType
iterator lower_bound(const KeyType &key)
size_t Insert(const KeyType &key, ValueType *value, int index=-1)
const BitsetType & bits() const
ValueType * Locate(const KeyType &key)
std::map< KeyType, ValueType * > MapType
void Remove(const KeyType &key, int index, bool clear_bit=true)
void ReserveBit(int index)
const_iterator clower_bound(const KeyType &key)
ValueType * Find(const KeyType &key) const
MapType::const_iterator const_iterator
void STLDeleteValues(Container *container)