21 #ifndef TULIP_STABLEITERATOR_H 22 #define TULIP_STABLEITERATOR_H 23 #include <tulip/Iterator.h> 24 #include <tulip/tulipconf.h> 56 template<
class itType>
57 struct StableIterator :
public Iterator<itType> {
66 StableIterator(
Iterator<itType> *inputIterator,
size_t nbElements = 0,
bool deleteIterator =
true,
bool sortCopy =
false) {
67 sequenceCopy.reserve(nbElements);
69 for (; inputIterator->
hasNext();) {
70 sequenceCopy.push_back(inputIterator->
next());
77 std::sort(sequenceCopy.begin(), sequenceCopy.end());
79 copyIterator = sequenceCopy.begin();
85 itType tmp(*copyIterator);
91 return (copyIterator != sequenceCopy.end());
101 copyIterator = sequenceCopy.begin();
108 std::vector<itType> sequenceCopy;
113 typename std::vector<itType>::const_iterator copyIterator;
virtual itType next()=0
Moves the Iterator on the next element.
Interface for Tulip iterators. Allows basic iteration operations only.
virtual bool hasNext()=0
Tells if the sequence is at its end.