Changeset 2384:805c5a2a36dd in lemon-0.x for lemon/bits
- Timestamp:
- 03/01/07 18:14:24 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3215
- Location:
- lemon/bits
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/alteration_notifier.h
r2305 r2384 144 144 /// Default constructor for ObserverBase. 145 145 /// 146 ObserverBase() : notifier(0) {}146 ObserverBase() : _notifier(0) {} 147 147 148 148 /// \brief Constructor which attach the observer into notifier. 149 149 /// 150 150 /// Constructor which attach the observer into notifier. 151 ObserverBase(AlterationNotifier& _notifier) {152 attach( _notifier);151 ObserverBase(AlterationNotifier& notifier) { 152 attach(notifier); 153 153 } 154 154 … … 159 159 ObserverBase(const ObserverBase& copy) { 160 160 if (copy.attached()) { 161 attach(*copy. getNotifier());161 attach(*copy._notifier()); 162 162 } 163 163 } … … 174 174 /// This member attaches the observer into an AlterationNotifier. 175 175 /// 176 void attach(AlterationNotifier& _notifier) {177 _notifier.attach(*this);176 void attach(AlterationNotifier& notifier) { 177 notifier.attach(*this); 178 178 } 179 179 … … 183 183 /// 184 184 void detach() { 185 notifier->detach(*this);185 _notifier->detach(*this); 186 186 } 187 187 … … 192 192 /// attached into. 193 193 /// 194 Notifier* getNotifier() const { return const_cast<Notifier*>(notifier); }194 Notifier* notifier() const { return const_cast<Notifier*>(_notifier); } 195 195 196 196 /// Gives back true when the observer is attached into a notifier. 197 bool attached() const { return notifier != 0; }197 bool attached() const { return _notifier != 0; } 198 198 199 199 private: … … 203 203 protected: 204 204 205 Notifier* notifier;206 typename std::list<ObserverBase*>::iterator index;205 Notifier* _notifier; 206 typename std::list<ObserverBase*>::iterator _index; 207 207 208 208 /// \brief The member function to notificate the observer about an … … 262 262 263 263 typedef std::list<ObserverBase*> Observers; 264 Observers observers;264 Observers _observers; 265 265 266 266 … … 294 294 ~AlterationNotifier() { 295 295 typename Observers::iterator it; 296 for (it = observers.begin(); it !=observers.end(); ++it) {297 (*it)-> notifier = 0;296 for (it = _observers.begin(); it != _observers.end(); ++it) { 297 (*it)->_notifier = 0; 298 298 } 299 299 } … … 347 347 348 348 void attach(ObserverBase& observer) { 349 observer. index = observers.insert(observers.begin(), &observer);350 observer. notifier = this;349 observer._index = _observers.insert(_observers.begin(), &observer); 350 observer._notifier = this; 351 351 } 352 352 353 353 void detach(ObserverBase& observer) { 354 observers.erase(observer.index);355 observer. index =observers.end();356 observer. notifier = 0;354 _observers.erase(observer._index); 355 observer._index = _observers.end(); 356 observer._notifier = 0; 357 357 } 358 358 … … 368 368 typename Observers::reverse_iterator it; 369 369 try { 370 for (it = observers.rbegin(); it !=observers.rend(); ++it) {370 for (it = _observers.rbegin(); it != _observers.rend(); ++it) { 371 371 (*it)->add(item); 372 372 } 373 373 } catch (...) { 374 374 typename Observers::iterator jt; 375 for (jt = it.base(); jt != observers.end(); ++jt) {375 for (jt = it.base(); jt != _observers.end(); ++jt) { 376 376 (*jt)->erase(item); 377 377 } … … 389 389 typename Observers::reverse_iterator it; 390 390 try { 391 for (it = observers.rbegin(); it !=observers.rend(); ++it) {391 for (it = _observers.rbegin(); it != _observers.rend(); ++it) { 392 392 (*it)->add(items); 393 393 } 394 394 } catch (...) { 395 395 typename Observers::iterator jt; 396 for (jt = it.base(); jt != observers.end(); ++jt) {396 for (jt = it.base(); jt != _observers.end(); ++jt) { 397 397 (*jt)->erase(items); 398 398 } … … 408 408 /// 409 409 void erase(const Item& item) throw() { 410 typename Observers::iterator it = observers.begin();411 while (it != observers.end()) {410 typename Observers::iterator it = _observers.begin(); 411 while (it != _observers.end()) { 412 412 try { 413 413 (*it)->erase(item); 414 414 ++it; 415 415 } catch (const ImmediateDetach&) { 416 it = observers.erase(it);417 (*it)-> index =observers.end();418 (*it)-> notifier = 0;416 it = _observers.erase(it); 417 (*it)->_index = _observers.end(); 418 (*it)->_notifier = 0; 419 419 } 420 420 } … … 428 428 /// 429 429 void erase(const std::vector<Item>& items) { 430 typename Observers::iterator it = observers.begin();431 while (it != observers.end()) {430 typename Observers::iterator it = _observers.begin(); 431 while (it != _observers.end()) { 432 432 try { 433 433 (*it)->erase(items); 434 434 ++it; 435 435 } catch (const ImmediateDetach&) { 436 it = observers.erase(it);437 (*it)-> index =observers.end();438 (*it)-> notifier = 0;436 it = _observers.erase(it); 437 (*it)->_index = _observers.end(); 438 (*it)->_notifier = 0; 439 439 } 440 440 } … … 449 449 typename Observers::reverse_iterator it; 450 450 try { 451 for (it = observers.rbegin(); it !=observers.rend(); ++it) {451 for (it = _observers.rbegin(); it != _observers.rend(); ++it) { 452 452 (*it)->build(); 453 453 } 454 454 } catch (...) { 455 455 typename Observers::iterator jt; 456 for (jt = it.base(); jt != observers.end(); ++jt) {456 for (jt = it.base(); jt != _observers.end(); ++jt) { 457 457 (*jt)->clear(); 458 458 } … … 467 467 /// from the container. 468 468 void clear() { 469 typename Observers::iterator it = observers.begin();470 while (it != observers.end()) {469 typename Observers::iterator it = _observers.begin(); 470 while (it != _observers.end()) { 471 471 try { 472 472 (*it)->clear(); 473 473 ++it; 474 474 } catch (const ImmediateDetach&) { 475 it = observers.erase(it);476 (*it)-> index =observers.end();477 (*it)-> notifier = 0;475 it = _observers.erase(it); 476 (*it)->_index = _observers.end(); 477 (*it)->_notifier = 0; 478 478 } 479 479 } -
lemon/bits/array_map.h
r2260 r2384 80 80 /// Graph initialized map constructor. 81 81 explicit ArrayMap(const Graph& graph) { 82 Parent::attach(graph. getNotifier(Item()));82 Parent::attach(graph.notifier(Item())); 83 83 allocate_memory(); 84 Notifier* notifier = Parent:: getNotifier();84 Notifier* notifier = Parent::notifier(); 85 85 Item it; 86 86 for (notifier->first(it); it != INVALID; notifier->next(it)) { … … 94 94 /// It constructs a map and initialize all of the the map. 95 95 ArrayMap(const Graph& graph, const Value& value) { 96 Parent::attach(graph. getNotifier(Item()));96 Parent::attach(graph.notifier(Item())); 97 97 allocate_memory(); 98 Notifier* notifier = Parent:: getNotifier();98 Notifier* notifier = Parent::notifier(); 99 99 Item it; 100 100 for (notifier->first(it); it != INVALID; notifier->next(it)) { … … 109 109 ArrayMap(const ArrayMap& copy) : Parent() { 110 110 if (copy.attached()) { 111 attach(*copy. getNotifier());111 attach(*copy.notifier()); 112 112 } 113 113 capacity = copy.capacity; 114 114 if (capacity == 0) return; 115 115 values = allocator.allocate(capacity); 116 Notifier* notifier = Parent:: getNotifier();116 Notifier* notifier = Parent::notifier(); 117 117 Item it; 118 118 for (notifier->first(it); it != INVALID; notifier->next(it)) { … … 143 143 ArrayMap& operator=(const CMap& cmap) { 144 144 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); 145 const typename Parent::Notifier* notifier = Parent:: getNotifier();145 const typename Parent::Notifier* notifier = Parent::notifier(); 146 146 Item it; 147 147 for (notifier->first(it); it != INVALID; notifier->next(it)) { … … 174 174 /// actual keys of the graph. 175 175 Value& operator[](const Key& key) { 176 int id = Parent:: getNotifier()->id(key);176 int id = Parent::notifier()->id(key); 177 177 return values[id]; 178 178 } … … 183 183 /// actual keys of the graph. 184 184 const Value& operator[](const Key& key) const { 185 int id = Parent:: getNotifier()->id(key);185 int id = Parent::notifier()->id(key); 186 186 return values[id]; 187 187 } … … 202 202 /// and it overrides the add() member function of the observer base. 203 203 virtual void add(const Key& key) { 204 Notifier* notifier = Parent:: getNotifier();204 Notifier* notifier = Parent::notifier(); 205 205 int id = notifier->id(key); 206 206 if (id >= capacity) { … … 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* notifier = Parent:: getNotifier();232 Notifier* notifier = Parent::notifier(); 233 233 int max_id = -1; 234 234 for (int i = 0; i < (int)keys.size(); ++i) { … … 274 274 /// and it overrides the erase() member function of the observer base. 275 275 virtual void erase(const Key& key) { 276 int id = Parent:: getNotifier()->id(key);276 int id = Parent::notifier()->id(key); 277 277 allocator.destroy(&(values[id])); 278 278 } … … 284 284 virtual void erase(const std::vector<Key>& keys) { 285 285 for (int i = 0; i < (int)keys.size(); ++i) { 286 int id = Parent:: getNotifier()->id(keys[i]);286 int id = Parent::notifier()->id(keys[i]); 287 287 allocator.destroy(&(values[id])); 288 288 } … … 294 294 /// and it overrides the build() member function of the observer base. 295 295 virtual void build() { 296 Notifier* notifier = Parent:: getNotifier();296 Notifier* notifier = Parent::notifier(); 297 297 allocate_memory(); 298 298 Item it; … … 308 308 /// and it overrides the clear() member function of the observer base. 309 309 virtual void clear() { 310 Notifier* notifier = Parent:: getNotifier();310 Notifier* notifier = Parent::notifier(); 311 311 if (capacity != 0) { 312 312 Item it; … … 323 323 324 324 void allocate_memory() { 325 int max_id = Parent:: getNotifier()->maxId();325 int max_id = Parent::notifier()->maxId(); 326 326 if (max_id == -1) { 327 327 capacity = 0; -
lemon/bits/debug_map.h
r2333 r2384 112 112 /// It adds all the items of the graph to the map. 113 113 DebugMap(const Graph& graph) { 114 Parent::attach(graph. getNotifier(Item()));115 container.resize(Parent:: getNotifier()->maxId() + 1);116 flag.resize(Parent:: getNotifier()->maxId() + 1, false);117 const typename Parent::Notifier* notifier = Parent:: getNotifier();118 Item it; 119 for (notifier->first(it); it != INVALID; notifier->next(it)) { 120 flag[Parent:: getNotifier()->id(it)] = true;114 Parent::attach(graph.notifier(Item())); 115 container.resize(Parent::notifier()->maxId() + 1); 116 flag.resize(Parent::notifier()->maxId() + 1, false); 117 const typename Parent::Notifier* notifier = Parent::notifier(); 118 Item it; 119 for (notifier->first(it); it != INVALID; notifier->next(it)) { 120 flag[Parent::notifier()->id(it)] = true; 121 121 } 122 122 } … … 127 127 /// It adds all the items of the graph to the map. 128 128 DebugMap(const Graph& graph, const Value& value) { 129 Parent::attach(graph. getNotifier(Item()));130 container.resize(Parent:: getNotifier()->maxId() + 1, value);131 flag.resize(Parent:: getNotifier()->maxId() + 1, false);132 const typename Parent::Notifier* notifier = Parent:: getNotifier();133 Item it; 134 for (notifier->first(it); it != INVALID; notifier->next(it)) { 135 flag[Parent:: getNotifier()->id(it)] = true;129 Parent::attach(graph.notifier(Item())); 130 container.resize(Parent::notifier()->maxId() + 1, value); 131 flag.resize(Parent::notifier()->maxId() + 1, false); 132 const typename Parent::Notifier* notifier = Parent::notifier(); 133 Item it; 134 for (notifier->first(it); it != INVALID; notifier->next(it)) { 135 flag[Parent::notifier()->id(it)] = true; 136 136 } 137 137 } … … 142 142 DebugMap(const DebugMap& _copy) : Parent() { 143 143 if (_copy.attached()) { 144 Parent::attach(*_copy. getNotifier());144 Parent::attach(*_copy.notifier()); 145 145 container = _copy.container; 146 146 } 147 flag.resize(Parent:: getNotifier()->maxId() + 1, false);148 const typename Parent::Notifier* notifier = Parent:: getNotifier();149 Item it; 150 for (notifier->first(it); it != INVALID; notifier->next(it)) { 151 flag[Parent:: getNotifier()->id(it)] = true;152 LEMON_ASSERT(_copy.flag[Parent:: getNotifier()->id(it)], MapError());147 flag.resize(Parent::notifier()->maxId() + 1, false); 148 const typename Parent::Notifier* notifier = Parent::notifier(); 149 Item it; 150 for (notifier->first(it); it != INVALID; notifier->next(it)) { 151 flag[Parent::notifier()->id(it)] = true; 152 LEMON_ASSERT(_copy.flag[Parent::notifier()->id(it)], MapError()); 153 153 } 154 154 } … … 158 158 /// Destructor. 159 159 ~DebugMap() { 160 const typename Parent::Notifier* notifier = Parent:: getNotifier();160 const typename Parent::Notifier* notifier = Parent::notifier(); 161 161 if (notifier != 0) { 162 162 Item it; 163 163 for (notifier->first(it); it != INVALID; notifier->next(it)) { 164 LEMON_ASSERT(flag[Parent:: getNotifier()->id(it)], MapError());165 flag[Parent:: getNotifier()->id(it)] = false;164 LEMON_ASSERT(flag[Parent::notifier()->id(it)], MapError()); 165 flag[Parent::notifier()->id(it)] = false; 166 166 } 167 167 } … … 192 192 DebugMap& operator=(const CMap& cmap) { 193 193 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); 194 const typename Parent::Notifier* notifier = Parent:: getNotifier();194 const typename Parent::Notifier* notifier = Parent::notifier(); 195 195 Item it; 196 196 for (notifier->first(it); it != INVALID; notifier->next(it)) { … … 207 207 /// actual items of the graph. 208 208 Reference operator[](const Key& key) { 209 LEMON_ASSERT(flag[Parent:: getNotifier()->id(key)], MapError());210 return container[Parent:: getNotifier()->id(key)];209 LEMON_ASSERT(flag[Parent::notifier()->id(key)], MapError()); 210 return container[Parent::notifier()->id(key)]; 211 211 } 212 212 … … 216 216 /// actual items of the graph. 217 217 ConstReference operator[](const Key& key) const { 218 LEMON_ASSERT(flag[Parent:: getNotifier()->id(key)], MapError());219 return container[Parent:: getNotifier()->id(key)];218 LEMON_ASSERT(flag[Parent::notifier()->id(key)], MapError()); 219 return container[Parent::notifier()->id(key)]; 220 220 } 221 221 … … 235 235 /// and it overrides the add() member function of the observer base. 236 236 virtual void add(const Key& key) { 237 int id = Parent:: getNotifier()->id(key);237 int id = Parent::notifier()->id(key); 238 238 if (id >= (int)container.size()) { 239 239 container.resize(id + 1); 240 240 flag.resize(id + 1, false); 241 241 } 242 LEMON_ASSERT(!flag[Parent:: getNotifier()->id(key)], MapError());243 flag[Parent:: getNotifier()->id(key)] = true;242 LEMON_ASSERT(!flag[Parent::notifier()->id(key)], MapError()); 243 flag[Parent::notifier()->id(key)] = true; 244 244 if (strictCheck) { 245 245 std::vector<bool> fl(flag.size(), false); 246 const typename Parent::Notifier* notifier = Parent:: getNotifier();247 Item it; 248 for (notifier->first(it); it != INVALID; notifier->next(it)) { 249 int id = Parent:: getNotifier()->id(it);246 const typename Parent::Notifier* notifier = Parent::notifier(); 247 Item it; 248 for (notifier->first(it); it != INVALID; notifier->next(it)) { 249 int id = Parent::notifier()->id(it); 250 250 fl[id] = true; 251 251 } … … 261 261 int max = container.size() - 1; 262 262 for (int i = 0; i < (int)keys.size(); ++i) { 263 int id = Parent:: getNotifier()->id(keys[i]);263 int id = Parent::notifier()->id(keys[i]); 264 264 if (id >= max) { 265 265 max = id; … … 269 269 flag.resize(max + 1, false); 270 270 for (int i = 0; i < (int)keys.size(); ++i) { 271 LEMON_ASSERT(!flag[Parent:: getNotifier()->id(keys[i])], MapError());272 flag[Parent:: getNotifier()->id(keys[i])] = true;271 LEMON_ASSERT(!flag[Parent::notifier()->id(keys[i])], MapError()); 272 flag[Parent::notifier()->id(keys[i])] = true; 273 273 } 274 274 if (strictCheck) { 275 275 std::vector<bool> fl(flag.size(), false); 276 const typename Parent::Notifier* notifier = Parent:: getNotifier();277 Item it; 278 for (notifier->first(it); it != INVALID; notifier->next(it)) { 279 int id = Parent:: getNotifier()->id(it);276 const typename Parent::Notifier* notifier = Parent::notifier(); 277 Item it; 278 for (notifier->first(it); it != INVALID; notifier->next(it)) { 279 int id = Parent::notifier()->id(it); 280 280 fl[id] = true; 281 281 } … … 291 291 if (strictCheck) { 292 292 std::vector<bool> fl(flag.size(), false); 293 const typename Parent::Notifier* notifier = Parent:: getNotifier();294 Item it; 295 for (notifier->first(it); it != INVALID; notifier->next(it)) { 296 int id = Parent:: getNotifier()->id(it);293 const typename Parent::Notifier* notifier = Parent::notifier(); 294 Item it; 295 for (notifier->first(it); it != INVALID; notifier->next(it)) { 296 int id = Parent::notifier()->id(it); 297 297 fl[id] = true; 298 298 } 299 299 LEMON_ASSERT(fl == flag, MapError()); 300 300 } 301 container[Parent:: getNotifier()->id(key)] = Value();302 LEMON_ASSERT(flag[Parent:: getNotifier()->id(key)], MapError());303 flag[Parent:: getNotifier()->id(key)] = false;301 container[Parent::notifier()->id(key)] = Value(); 302 LEMON_ASSERT(flag[Parent::notifier()->id(key)], MapError()); 303 flag[Parent::notifier()->id(key)] = false; 304 304 } 305 305 … … 311 311 if (strictCheck) { 312 312 std::vector<bool> fl(flag.size(), false); 313 const typename Parent::Notifier* notifier = Parent:: getNotifier();314 Item it; 315 for (notifier->first(it); it != INVALID; notifier->next(it)) { 316 int id = Parent:: getNotifier()->id(it);313 const typename Parent::Notifier* notifier = Parent::notifier(); 314 Item it; 315 for (notifier->first(it); it != INVALID; notifier->next(it)) { 316 int id = Parent::notifier()->id(it); 317 317 fl[id] = true; 318 318 } … … 320 320 } 321 321 for (int i = 0; i < (int)keys.size(); ++i) { 322 container[Parent:: getNotifier()->id(keys[i])] = Value();323 LEMON_ASSERT(flag[Parent:: getNotifier()->id(keys[i])], MapError());324 flag[Parent:: getNotifier()->id(keys[i])] = false;322 container[Parent::notifier()->id(keys[i])] = Value(); 323 LEMON_ASSERT(flag[Parent::notifier()->id(keys[i])], MapError()); 324 flag[Parent::notifier()->id(keys[i])] = false; 325 325 } 326 326 } … … 336 336 } 337 337 } 338 int size = Parent:: getNotifier()->maxId() + 1;338 int size = Parent::notifier()->maxId() + 1; 339 339 container.reserve(size); 340 340 container.resize(size); 341 341 flag.reserve(size); 342 342 flag.resize(size, false); 343 const typename Parent::Notifier* notifier = Parent:: getNotifier();344 Item it; 345 for (notifier->first(it); it != INVALID; notifier->next(it)) { 346 int id = Parent:: getNotifier()->id(it);343 const typename Parent::Notifier* notifier = Parent::notifier(); 344 Item it; 345 for (notifier->first(it); it != INVALID; notifier->next(it)) { 346 int id = Parent::notifier()->id(it); 347 347 LEMON_ASSERT(!flag[id], MapError()); 348 348 flag[id] = true; … … 355 355 /// and it overrides the clear() member function of the observer base. 356 356 virtual void clear() { 357 const typename Parent::Notifier* notifier = Parent:: getNotifier();358 Item it; 359 for (notifier->first(it); it != INVALID; notifier->next(it)) { 360 int id = Parent:: getNotifier()->id(it);357 const typename Parent::Notifier* notifier = Parent::notifier(); 358 Item it; 359 for (notifier->first(it); it != INVALID; notifier->next(it)) { 360 int id = Parent::notifier()->id(it); 361 361 LEMON_ASSERT(flag[id], MapError()); 362 362 flag[id] = false; -
lemon/bits/edge_set_extender.h
r2046 r2384 82 82 public: 83 83 84 using Parent:: getNotifier;84 using Parent::notifier; 85 85 86 86 /// \brief Gives back the edge alteration notifier. 87 87 /// 88 88 /// Gives back the edge alteration notifier. 89 EdgeNotifier& getNotifier(Edge) const {89 EdgeNotifier& notifier(Edge) const { 90 90 return edge_notifier; 91 91 } … … 247 247 Edge addEdge(const Node& from, const Node& to) { 248 248 Edge edge = Parent::addEdge(from, to); 249 getNotifier(Edge()).add(edge);249 notifier(Edge()).add(edge); 250 250 return edge; 251 251 } 252 252 253 253 void clear() { 254 getNotifier(Edge()).clear();254 notifier(Edge()).clear(); 255 255 Parent::clear(); 256 256 } 257 257 258 258 void erase(const Edge& edge) { 259 getNotifier(Edge()).erase(edge);259 notifier(Edge()).erase(edge); 260 260 Parent::erase(edge); 261 261 } … … 341 341 public: 342 342 343 using Parent:: getNotifier;343 using Parent::notifier; 344 344 345 EdgeNotifier& getNotifier(Edge) const {345 EdgeNotifier& notifier(Edge) const { 346 346 return edge_notifier; 347 347 } 348 348 349 UEdgeNotifier& getNotifier(UEdge) const {349 UEdgeNotifier& notifier(UEdge) const { 350 350 return uedge_notifier; 351 351 } … … 590 590 UEdge addEdge(const Node& from, const Node& to) { 591 591 UEdge uedge = Parent::addEdge(from, to); 592 getNotifier(UEdge()).add(uedge);593 getNotifier(Edge()).add(Parent::direct(uedge, true));594 getNotifier(Edge()).add(Parent::direct(uedge, false));592 notifier(UEdge()).add(uedge); 593 notifier(Edge()).add(Parent::direct(uedge, true)); 594 notifier(Edge()).add(Parent::direct(uedge, false)); 595 595 return uedge; 596 596 } 597 597 598 598 void clear() { 599 getNotifier(Edge()).clear();600 getNotifier(UEdge()).clear();599 notifier(Edge()).clear(); 600 notifier(UEdge()).clear(); 601 601 Parent::clear(); 602 602 } 603 603 604 604 void erase(const UEdge& uedge) { 605 getNotifier(Edge()).erase(Parent::direct(uedge, true));606 getNotifier(Edge()).erase(Parent::direct(uedge, false));607 getNotifier(UEdge()).erase(uedge);605 notifier(Edge()).erase(Parent::direct(uedge, true)); 606 notifier(Edge()).erase(Parent::direct(uedge, false)); 607 notifier(UEdge()).erase(uedge); 608 608 Parent::erase(uedge); 609 609 } -
lemon/bits/graph_extender.h
r2329 r2384 87 87 public: 88 88 89 NodeNotifier& getNotifier(Node) const {89 NodeNotifier& notifier(Node) const { 90 90 return node_notifier; 91 91 } 92 92 93 EdgeNotifier& getNotifier(Edge) const {93 EdgeNotifier& notifier(Edge) const { 94 94 return edge_notifier; 95 95 } … … 267 267 Node addNode() { 268 268 Node node = Parent::addNode(); 269 getNotifier(Node()).add(node);269 notifier(Node()).add(node); 270 270 return node; 271 271 } … … 273 273 Edge addEdge(const Node& from, const Node& to) { 274 274 Edge edge = Parent::addEdge(from, to); 275 getNotifier(Edge()).add(edge);275 notifier(Edge()).add(edge); 276 276 return edge; 277 277 } 278 278 279 279 void clear() { 280 getNotifier(Edge()).clear();281 getNotifier(Node()).clear();280 notifier(Edge()).clear(); 281 notifier(Node()).clear(); 282 282 Parent::clear(); 283 283 } … … 286 286 void build(const Graph& graph, NodeRefMap& nodeRef, EdgeRefMap& edgeRef) { 287 287 Parent::build(graph, nodeRef, edgeRef); 288 getNotifier(Node()).build();289 getNotifier(Edge()).build();288 notifier(Node()).build(); 289 notifier(Edge()).build(); 290 290 } 291 291 … … 304 304 } 305 305 306 getNotifier(Node()).erase(node);306 notifier(Node()).erase(node); 307 307 Parent::erase(node); 308 308 } 309 309 310 310 void erase(const Edge& edge) { 311 getNotifier(Edge()).erase(edge);311 notifier(Edge()).erase(edge); 312 312 Parent::erase(edge); 313 313 } … … 398 398 public: 399 399 400 NodeNotifier& getNotifier(Node) const {400 NodeNotifier& notifier(Node) const { 401 401 return node_notifier; 402 402 } 403 403 404 EdgeNotifier& getNotifier(Edge) const {404 EdgeNotifier& notifier(Edge) const { 405 405 return edge_notifier; 406 406 } 407 407 408 UEdgeNotifier& getNotifier(UEdge) const {408 UEdgeNotifier& notifier(UEdge) const { 409 409 return uedge_notifier; 410 410 } … … 673 673 Node addNode() { 674 674 Node node = Parent::addNode(); 675 getNotifier(Node()).add(node);675 notifier(Node()).add(node); 676 676 return node; 677 677 } … … 679 679 UEdge addEdge(const Node& from, const Node& to) { 680 680 UEdge uedge = Parent::addEdge(from, to); 681 getNotifier(UEdge()).add(uedge);681 notifier(UEdge()).add(uedge); 682 682 std::vector<Edge> edges; 683 683 edges.push_back(Parent::direct(uedge, true)); 684 684 edges.push_back(Parent::direct(uedge, false)); 685 getNotifier(Edge()).add(edges);685 notifier(Edge()).add(edges); 686 686 return uedge; 687 687 } 688 688 689 689 void clear() { 690 getNotifier(Edge()).clear();691 getNotifier(UEdge()).clear();692 getNotifier(Node()).clear();690 notifier(Edge()).clear(); 691 notifier(UEdge()).clear(); 692 notifier(Node()).clear(); 693 693 Parent::clear(); 694 694 } … … 698 698 UEdgeRefMap& uEdgeRef) { 699 699 Parent::build(graph, nodeRef, uEdgeRef); 700 getNotifier(Node()).build();701 getNotifier(UEdge()).build();702 getNotifier(Edge()).build();700 notifier(Node()).build(); 701 notifier(UEdge()).build(); 702 notifier(Edge()).build(); 703 703 } 704 704 … … 717 717 } 718 718 719 getNotifier(Node()).erase(node);719 notifier(Node()).erase(node); 720 720 Parent::erase(node); 721 721 } … … 725 725 edges.push_back(Parent::direct(uedge, true)); 726 726 edges.push_back(Parent::direct(uedge, false)); 727 getNotifier(Edge()).erase(edges);728 getNotifier(UEdge()).erase(uedge);727 notifier(Edge()).erase(edges); 728 notifier(UEdge()).erase(uedge); 729 729 Parent::erase(uedge); 730 730 } … … 824 824 public: 825 825 826 NodeNotifier& getNotifier(Node) const {826 NodeNotifier& notifier(Node) const { 827 827 return node_notifier; 828 828 } 829 829 830 ANodeNotifier& getNotifier(ANode) const {830 ANodeNotifier& notifier(ANode) const { 831 831 return anode_notifier; 832 832 } 833 833 834 BNodeNotifier& getNotifier(BNode) const {834 BNodeNotifier& notifier(BNode) const { 835 835 return bnode_notifier; 836 836 } 837 837 838 EdgeNotifier& getNotifier(Edge) const {838 EdgeNotifier& notifier(Edge) const { 839 839 return edge_notifier; 840 840 } 841 841 842 UEdgeNotifier& getNotifier(UEdge) const {842 UEdgeNotifier& notifier(UEdge) const { 843 843 return uedge_notifier; 844 844 } … … 1284 1284 Node addANode() { 1285 1285 Node node = Parent::addANode(); 1286 getNotifier(ANode()).add(node);1287 getNotifier(Node()).add(node);1286 notifier(ANode()).add(node); 1287 notifier(Node()).add(node); 1288 1288 return node; 1289 1289 } … … 1291 1291 Node addBNode() { 1292 1292 Node node = Parent::addBNode(); 1293 getNotifier(BNode()).add(node);1294 getNotifier(Node()).add(node);1293 notifier(BNode()).add(node); 1294 notifier(Node()).add(node); 1295 1295 return node; 1296 1296 } … … 1298 1298 UEdge addEdge(const Node& source, const Node& target) { 1299 1299 UEdge uedge = Parent::addEdge(source, target); 1300 getNotifier(UEdge()).add(uedge);1300 notifier(UEdge()).add(uedge); 1301 1301 1302 1302 std::vector<Edge> edges; 1303 1303 edges.push_back(Parent::direct(uedge, true)); 1304 1304 edges.push_back(Parent::direct(uedge, false)); 1305 getNotifier(Edge()).add(edges);1305 notifier(Edge()).add(edges); 1306 1306 1307 1307 return uedge; … … 1309 1309 1310 1310 void clear() { 1311 getNotifier(Edge()).clear();1312 getNotifier(UEdge()).clear();1313 getNotifier(Node()).clear();1314 getNotifier(BNode()).clear();1315 getNotifier(ANode()).clear();1311 notifier(Edge()).clear(); 1312 notifier(UEdge()).clear(); 1313 notifier(Node()).clear(); 1314 notifier(BNode()).clear(); 1315 notifier(ANode()).clear(); 1316 1316 Parent::clear(); 1317 1317 } … … 1322 1322 BNodeRefMap& bNodeRef, UEdgeRefMap& uEdgeRef) { 1323 1323 Parent::build(graph, aNodeRef, bNodeRef, uEdgeRef); 1324 getNotifier(ANode()).build();1325 getNotifier(BNode()).build();1326 getNotifier(Node()).build();1327 getNotifier(UEdge()).build();1328 getNotifier(Edge()).build();1324 notifier(ANode()).build(); 1325 notifier(BNode()).build(); 1326 notifier(Node()).build(); 1327 notifier(UEdge()).build(); 1328 notifier(Edge()).build(); 1329 1329 } 1330 1330 … … 1337 1337 Parent::firstFromANode(uedge, node); 1338 1338 } 1339 getNotifier(ANode()).erase(node);1339 notifier(ANode()).erase(node); 1340 1340 } else { 1341 1341 Parent::firstFromBNode(uedge, node); … … 1344 1344 Parent::firstFromBNode(uedge, node); 1345 1345 } 1346 getNotifier(BNode()).erase(node);1347 } 1348 1349 getNotifier(Node()).erase(node);1346 notifier(BNode()).erase(node); 1347 } 1348 1349 notifier(Node()).erase(node); 1350 1350 Parent::erase(node); 1351 1351 } … … 1355 1355 edges.push_back(Parent::direct(uedge, true)); 1356 1356 edges.push_back(Parent::direct(uedge, false)); 1357 getNotifier(Edge()).erase(edges);1358 getNotifier(UEdge()).erase(uedge);1357 notifier(Edge()).erase(edges); 1358 notifier(UEdge()).erase(uedge); 1359 1359 Parent::erase(uedge); 1360 1360 } -
lemon/bits/map_extender.h
r2260 r2384 84 84 85 85 explicit MapIt(Map& _map) : map(_map) { 86 map. getNotifier()->first(*this);86 map.notifier()->first(*this); 87 87 } 88 88 … … 91 91 92 92 MapIt& operator++() { 93 map. getNotifier()->next(*this);93 map.notifier()->next(*this); 94 94 return *this; 95 95 } … … 124 124 125 125 explicit ConstMapIt(Map& _map) : map(_map) { 126 map. getNotifier()->first(*this);126 map.notifier()->first(*this); 127 127 } 128 128 … … 131 131 132 132 ConstMapIt& operator++() { 133 map. getNotifier()->next(*this);133 map.notifier()->next(*this); 134 134 return *this; 135 135 } … … 153 153 154 154 explicit ItemIt(Map& _map) : map(_map) { 155 map. getNotifier()->first(*this);155 map.notifier()->first(*this); 156 156 } 157 157 … … 160 160 161 161 ItemIt& operator++() { 162 map. getNotifier()->next(*this);162 map.notifier()->next(*this); 163 163 return *this; 164 164 } -
lemon/bits/vector_map.h
r2260 r2384 91 91 /// It adds all the items of the graph to the map. 92 92 VectorMap(const Graph& graph) { 93 Parent::attach(graph. getNotifier(Item()));94 container.resize(Parent:: getNotifier()->maxId() + 1);93 Parent::attach(graph.notifier(Item())); 94 container.resize(Parent::notifier()->maxId() + 1); 95 95 } 96 96 … … 100 100 /// It adds all the items of the graph to the map. 101 101 VectorMap(const Graph& graph, const Value& value) { 102 Parent::attach(graph. getNotifier(Item()));103 container.resize(Parent:: getNotifier()->maxId() + 1, value);102 Parent::attach(graph.notifier(Item())); 103 container.resize(Parent::notifier()->maxId() + 1, value); 104 104 } 105 105 … … 109 109 VectorMap(const VectorMap& _copy) : Parent() { 110 110 if (_copy.attached()) { 111 Parent::attach(*_copy. getNotifier());111 Parent::attach(*_copy.notifier()); 112 112 container = _copy.container; 113 113 } … … 135 135 VectorMap& operator=(const CMap& cmap) { 136 136 checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); 137 const typename Parent::Notifier* notifier = Parent:: getNotifier();137 const typename Parent::Notifier* notifier = Parent::notifier(); 138 138 Item it; 139 139 for (notifier->first(it); it != INVALID; notifier->next(it)) { … … 150 150 /// actual items of the graph. 151 151 Reference operator[](const Key& key) { 152 return container[Parent:: getNotifier()->id(key)];152 return container[Parent::notifier()->id(key)]; 153 153 } 154 154 … … 158 158 /// actual items of the graph. 159 159 ConstReference operator[](const Key& key) const { 160 return container[Parent:: getNotifier()->id(key)];160 return container[Parent::notifier()->id(key)]; 161 161 } 162 162 … … 176 176 /// and it overrides the add() member function of the observer base. 177 177 virtual void add(const Key& key) { 178 int id = Parent:: getNotifier()->id(key);178 int id = Parent::notifier()->id(key); 179 179 if (id >= (int)container.size()) { 180 180 container.resize(id + 1); … … 189 189 int max = container.size() - 1; 190 190 for (int i = 0; i < (int)keys.size(); ++i) { 191 int id = Parent:: getNotifier()->id(keys[i]);191 int id = Parent::notifier()->id(keys[i]); 192 192 if (id >= max) { 193 193 max = id; … … 202 202 /// and it overrides the erase() member function of the observer base. 203 203 virtual void erase(const Key& key) { 204 container[Parent:: getNotifier()->id(key)] = Value();204 container[Parent::notifier()->id(key)] = Value(); 205 205 } 206 206 … … 211 211 virtual void erase(const std::vector<Key>& keys) { 212 212 for (int i = 0; i < (int)keys.size(); ++i) { 213 container[Parent:: getNotifier()->id(keys[i])] = Value();213 container[Parent::notifier()->id(keys[i])] = Value(); 214 214 } 215 215 } … … 220 220 /// and it overrides the build() member function of the observer base. 221 221 virtual void build() { 222 int size = Parent:: getNotifier()->maxId() + 1;222 int size = Parent::notifier()->maxId() + 1; 223 223 container.reserve(size); 224 224 container.resize(size);
Note: See TracChangeset
for help on using the changeset viewer.