tlp::StableIterator< itType > Class Template Reference
[Iterators]
That class enables to store elements of an iterator and to iterate on a copy.
More...
#include <StableIterator.h>
List of all members.
Public Member Functions
Protected Attributes
- std::vector< itType > cloneIt
- std::vector< itType >
::const_iterator itStl
Detailed Description
template<class itType>
class tlp::StableIterator< itType >
That class enables to store elements of an iterator and to iterate on a copy.
That iterator store all elements accessible by the input iterator into an internal data structure (created at the construction) and then only use that structure for the iteration. Order of iteration is the same. If one knows the number of elements that will be iterated one could give give it in paremeters to speed up the duplication process.
- Warning:
- By default StableIterator manage the destruction of the iterator given in parameter, (ie, delete will be call on the input iterator).
That class is really useful when one need to modify the graph during an iteration. For instance the following code remove all nodes that match the function myfunc(). Using standard iterators for that operations is not possible since we modify the graph.
StableIterator<node> it(graph->getNodes());
while(it.hasNext()) {
node n = it.next();
if (myfunc(n))
graph->delNode(n);
}
- See also:
- stableForEach
Constructor & Destructor Documentation
Member Function Documentation
Enables to restart the iteration at the begining.
Member Data Documentation