5 #ifndef ctrlplane_index_map_h
6 #define ctrlplane_index_map_h
17 template <
typename KeyType,
typename ValueType,
18 typename BitsetType =
BitSet>
22 typedef std::map<KeyType, ValueType *>
MapType;
35 typename MapType::const_iterator loc =
map_.find(key);
36 if (loc !=
map_.end()) {
43 if (
bits_.test(index))
51 std::pair<typename MapType::iterator, bool> result =
52 map_.insert(std::make_pair(key, value));
58 bit =
bits_.find_first_clear();
69 void Remove(
const KeyType &key,
int index,
bool clear_bit =
true) {
70 typename MapType::iterator loc =
map_.find(key);
71 assert(loc !=
map_.end());
72 assert(loc->second ==
values_[index]);
83 for (int64_t i =
values_.size() - 1; i >= 0; i--) {
95 value->set_index(
Insert(key, value));
115 return map_.lower_bound(key);
120 return map_.lower_bound(key);
std::vector< ValueType * > VectorType
void STLDeleteValues(Container *container)
void ReserveBit(int index)
const_iterator clower_bound(const KeyType &key)
ValueType * At(int index) const
void Remove(const KeyType &key, int index, bool clear_bit=true)
iterator lower_bound(const KeyType &key)
const BitsetType & bits() const
MapType::const_iterator const_iterator
MapType::iterator iterator
std::map< KeyType, ValueType * > MapType
DISALLOW_COPY_AND_ASSIGN(IndexMap)
ValueType * Find(const KeyType &key) const
size_t Insert(const KeyType &key, ValueType *value, int index=-1)
ValueType * Locate(const KeyType &key)