Changeset 2386:81b47fc5c444 in lemon-0.x for lemon/bits/array_map.h
- Timestamp:
- 03/02/07 19:04:28 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3217
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/array_map.h
r2384 r2386 82 82 Parent::attach(graph.notifier(Item())); 83 83 allocate_memory(); 84 Notifier* n otifier= Parent::notifier();85 Item it; 86 for (n otifier->first(it); it != INVALID; notifier->next(it)) {87 int id = n otifier->id(it);;84 Notifier* nf = Parent::notifier(); 85 Item it; 86 for (nf->first(it); it != INVALID; nf->next(it)) { 87 int id = nf->id(it);; 88 88 allocator.construct(&(values[id]), Value()); 89 89 } … … 96 96 Parent::attach(graph.notifier(Item())); 97 97 allocate_memory(); 98 Notifier* n otifier= Parent::notifier();99 Item it; 100 for (n otifier->first(it); it != INVALID; notifier->next(it)) {101 int id = n otifier->id(it);;98 Notifier* nf = Parent::notifier(); 99 Item it; 100 for (nf->first(it); it != INVALID; nf->next(it)) { 101 int id = nf->id(it);; 102 102 allocator.construct(&(values[id]), value); 103 103 } … … 114 114 if (capacity == 0) return; 115 115 values = allocator.allocate(capacity); 116 Notifier* n otifier= Parent::notifier();117 Item it; 118 for (n otifier->first(it); it != INVALID; notifier->next(it)) {119 int id = n otifier->id(it);;116 Notifier* nf = Parent::notifier(); 117 Item it; 118 for (nf->first(it); it != INVALID; nf->next(it)) { 119 int id = nf->id(it);; 120 120 allocator.construct(&(values[id]), copy.values[id]); 121 121 } … … 143 143 ArrayMap& operator=(const CMap& cmap) { 144 144 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); 145 const typename Parent::Notifier* n otifier= Parent::notifier();146 Item it; 147 for (n otifier->first(it); it != INVALID; notifier->next(it)) {145 const typename Parent::Notifier* nf = Parent::notifier(); 146 Item it; 147 for (nf->first(it); it != INVALID; nf->next(it)) { 148 148 set(it, cmap[it]); 149 149 } … … 202 202 /// and it overrides the add() member function of the observer base. 203 203 virtual void add(const Key& key) { 204 Notifier* n otifier= Parent::notifier();205 int id = n otifier->id(key);204 Notifier* nf = Parent::notifier(); 205 int id = nf->id(key); 206 206 if (id >= capacity) { 207 207 int new_capacity = (capacity == 0 ? 1 : capacity); … … 211 211 Value* new_values = allocator.allocate(new_capacity); 212 212 Item it; 213 for (n otifier->first(it); it != INVALID; notifier->next(it)) {214 int jd = n otifier->id(it);;213 for (nf->first(it); it != INVALID; nf->next(it)) { 214 int jd = nf->id(it);; 215 215 if (id != jd) { 216 216 allocator.construct(&(new_values[jd]), values[jd]); … … 230 230 /// and it overrides the add() member function of the observer base. 231 231 virtual void add(const std::vector<Key>& keys) { 232 Notifier* n otifier= Parent::notifier();232 Notifier* nf = Parent::notifier(); 233 233 int max_id = -1; 234 for (int i = 0; i < (int)keys.size(); ++i) {235 int id = n otifier->id(keys[i]);234 for (int i = 0; i < int(keys.size()); ++i) { 235 int id = nf->id(keys[i]); 236 236 if (id > max_id) { 237 237 max_id = id; … … 245 245 Value* new_values = allocator.allocate(new_capacity); 246 246 Item it; 247 for (n otifier->first(it); it != INVALID; notifier->next(it)) {248 int id = n otifier->id(it);247 for (nf->first(it); it != INVALID; nf->next(it)) { 248 int id = nf->id(it); 249 249 bool found = false; 250 for (int i = 0; i < (int)keys.size(); ++i) {251 int jd = n otifier->id(keys[i]);250 for (int i = 0; i < int(keys.size()); ++i) { 251 int jd = nf->id(keys[i]); 252 252 if (id == jd) { 253 253 found = true; … … 263 263 capacity = new_capacity; 264 264 } 265 for (int i = 0; i < (int)keys.size(); ++i) {266 int id = n otifier->id(keys[i]);265 for (int i = 0; i < int(keys.size()); ++i) { 266 int id = nf->id(keys[i]); 267 267 allocator.construct(&(values[id]), Value()); 268 268 } … … 283 283 /// and it overrides the erase() member function of the observer base. 284 284 virtual void erase(const std::vector<Key>& keys) { 285 for (int i = 0; i < (int)keys.size(); ++i) {285 for (int i = 0; i < int(keys.size()); ++i) { 286 286 int id = Parent::notifier()->id(keys[i]); 287 287 allocator.destroy(&(values[id])); … … 294 294 /// and it overrides the build() member function of the observer base. 295 295 virtual void build() { 296 Notifier* n otifier= Parent::notifier();296 Notifier* nf = Parent::notifier(); 297 297 allocate_memory(); 298 298 Item it; 299 for (n otifier->first(it); it != INVALID; notifier->next(it)) {300 int id = n otifier->id(it);;299 for (nf->first(it); it != INVALID; nf->next(it)) { 300 int id = nf->id(it);; 301 301 allocator.construct(&(values[id]), Value()); 302 302 } … … 308 308 /// and it overrides the clear() member function of the observer base. 309 309 virtual void clear() { 310 Notifier* n otifier= Parent::notifier();310 Notifier* nf = Parent::notifier(); 311 311 if (capacity != 0) { 312 312 Item it; 313 for (n otifier->first(it); it != INVALID; notifier->next(it)) {314 int id = n otifier->id(it);313 for (nf->first(it); it != INVALID; nf->next(it)) { 314 int id = nf->id(it); 315 315 allocator.destroy(&(values[id])); 316 316 }
Note: See TracChangeset
for help on using the changeset viewer.