31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

used only as a “Trojan horse,” which carries the pointer to the counter without affecting<br />

the code of the algorithm.<br />

template<br />

bool break_condition (const Iter&) { ... }<br />

template<br />

void dummy_algorithm(ONodeIt& it, OAdjIt& it2) {<br />

while (it.valid()) {<br />

for (it2.update(it); it2.valid() && !break_condition(it2); ++it2)<br />

++it;<br />

}<br />

}<br />

int write_count(graph& G) {<br />

typedef DummyObserver<br />

typedef SimpleCountObserver<br />

typedef ObserverNodeIt<br />

typedef ObserverAdjIt<br />

DummyObs;<br />

CountObs;<br />

ONodeIt;<br />

OAdjIt;<br />

}<br />

DummyObs observer;<br />

ONodeIt it(observer,NodeIt(G));<br />

CountObs observer2(observer);<br />

OAdjIt it2(observer2,AdjIt(G));<br />

dummy_algorithm(it,it2);<br />

return it2.get_observer().counter();<br />

13.12 STL Iterator Wrapper ( STLNodeIt )<br />

1. Definition<br />

An instance it of class STLNodeIt< DataAccessor, Iter > is a STL iterator wrapper for<br />

node iterators (e.g. NodeIt, FilterNodeIt). It adds all type tags and<br />

methods that are necessary for STL conformance; see the standard draft working paper<br />

for details. <strong>The</strong> type tag value type is equal to typename DataAccessor::value type<br />

and the return value of operator*.<br />

Class STLEdgeIt and STLAdjIt are defined analogously, i.e. can be used for edge iterators<br />

or adjacency iterators, respectively.<br />

Precondition: <strong>The</strong> template parameter Iter must be a node iterator. DataAccessor<br />

must be a data accessor.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!