Tulip
6.0.0
Large graphs analysis and drawing
|
#include <StableIterator.h>
Public Member Functions | |
StableIterator (Iterator< T > *inputIterator, size_t nbElements=0, bool deleteIterator=true, bool sortCopy=false) | |
bool | hasNext () |
T | next () |
void | restart () |
Public Member Functions inherited from tlp::Iterator< T > | |
iterator_t | begin () |
iterator_t | end () |
Protected Attributes | |
std::vector< T >::const_iterator | copyIterator |
std::vector< T > | sequenceCopy |
Stores the elements of an iterator and iterates a copy.
This Iterator stores all the elements accessible by another Iterator into an internal data structure (created at the construction), and then uses this structure for the iteration. Iteration order is the same.
This class is really useful when one needs 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 operation is not possible since we modify the graph.
Definition at line 60 of file StableIterator.h.
|
inline |
Creates a stable Iterator, that allows to delete elements from a graph while iterating on them.
inputIterator | Input Iterator, which defines the sequence on which this Iterator will iterate. |
nbElements | The number of elements the iteration will take place on. Defaults to 0. |
deleteIterator | Whether or not to delete the Iterator given as first parameter. Defaults to true. |
Definition at line 72 of file StableIterator.h.
|
inlinevirtual |
Tells if the sequence is at its end.
Implements tlp::Iterator< T >.
Definition at line 97 of file StableIterator.h.
|
inlinevirtual |
Moves the Iterator on the next element.
Implements tlp::Iterator< T >.
Definition at line 91 of file StableIterator.h.
|
inline |
Restarts the iteration by moving the Iterator to the beginning of the sequence.
Definition at line 107 of file StableIterator.h.
|
protected |
STL const_iterator on the cloned sequence.
Definition at line 120 of file StableIterator.h.
|
protected |
A copy of the sequence of the elements to iterate.
Definition at line 115 of file StableIterator.h.