Changeset 1703:eb90e3d6bddc in lemon-0.x for lemon/bits/array_map.h
- Timestamp:
- 10/05/05 15:15:47 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2230
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/array_map.h
r1669 r1703 49 49 typedef _Item Item; 50 50 public: 51 typedef True AdaptibleTag; 51 52 52 53 /// The graph type of the maps. … … 70 71 public: 71 72 73 /// \brief Graph and Registry initialized map constructor. 74 /// 72 75 /// Graph and Registry initialized map constructor. 73 76 ArrayMap(const Graph& _g) : graph(&_g) { … … 81 84 } 82 85 83 /// Constructor to use default value to initialize the map. 84 85 /// It constrates a map and initialize all of the the map. 86 86 /// \brief Constructor to use default value to initialize the map. 87 /// 88 /// It constructs a map and initialize all of the the map. 87 89 ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) { 88 90 Item it; … … 95 97 } 96 98 97 /// Constructor to copy a map of the same map type. 98 99 /// \brief Constructor to copy a map of the same map type. 100 /// 101 /// Constructor to copy a map of the same map type. 99 102 ArrayMap(const ArrayMap& copy) : Parent(), graph(copy.graph) { 100 103 if (copy.attached()) { … … 138 141 public: 139 142 140 ///The subscript operator. The map can be subscripted by the 141 ///actual keys of the graph. 142 143 /// \brief The subscript operator. 144 /// 145 /// The subscript operator. The map can be subscripted by the 146 /// actual keys of the graph. 143 147 Value& operator[](const Key& key) { 144 148 int id = graph->id(key); … … 146 150 } 147 151 148 149 /// The const subscript operator. The map can be subscripted by the150 /// actual keys of the graph.151 152 /// \brief The const subscript operator. 153 /// 154 /// The const subscript operator. The map can be subscripted by the 155 /// actual keys of the graph. 152 156 const Value& operator[](const Key& key) const { 153 157 int id = graph->id(key); 154 158 return values[id]; 155 159 } 156 160 161 /// \brief Setter function of the map. 162 /// 157 163 /// Setter function of the map. Equivalent with map[key] = val. 158 164 /// This is a compatibility feature with the not dereferable maps. 159 160 165 void set(const Key& key, const Value& val) { 161 166 (*this)[key] = val; … … 163 168 164 169 protected: 165 170 166 171 /// Add a new key to the map. It called by the map registry. 167 168 v oid add(const Key& key) {172 173 virtual void add(const Key& key) { 169 174 int id = graph->id(key); 170 175 if (id >= capacity) { … … 189 194 } 190 195 191 v oid add(const std::vector<Key>& keys) {196 virtual void add(const std::vector<Key>& keys) { 192 197 int max_id = -1; 193 198 for (int i = 0; i < (int)keys.size(); ++i) { … … 230 235 /// Erase a key from the map. It called by the map registry. 231 236 232 v oid erase(const Key& key) {237 virtual void erase(const Key& key) { 233 238 int id = graph->id(key); 234 239 allocator.destroy(&(values[id])); 235 240 } 236 241 237 v oid erase(const std::vector<Key>& keys) {242 virtual void erase(const std::vector<Key>& keys) { 238 243 for (int i = 0; i < (int)keys.size(); ++i) { 239 244 int id = graph->id(keys[i]); … … 242 247 } 243 248 244 v oid build() {249 virtual void build() { 245 250 allocate_memory(); 246 251 Item it; … … 251 256 } 252 257 253 v oid clear() {258 virtual void clear() { 254 259 if (capacity != 0) { 255 260 Item it;
Note: See TracChangeset
for help on using the changeset viewer.