20 #ifndef TULIP_ITERATOR_H 
   21 #define TULIP_ITERATOR_H 
   29 #include <tulip/tulipconf.h> 
   35 extern TLP_SCOPE 
void incrNumIterators();
 
   36 extern TLP_SCOPE 
void decrNumIterators();
 
   37 extern TLP_SCOPE 
int getNumIterators();
 
  105     enum IteratorStatus { Begin = 0, Finished = 1, End = 3 };
 
  107     IteratorStatus _iteratorStatus;
 
  110     iterator_t(
Iterator<T> *it, IteratorStatus iteratorStatus = End)
 
  111         : _iteratorStatus(iteratorStatus), _it(it) {
 
  112       if ((_iteratorStatus == Begin) && (_it->
hasNext() == 
false)) {
 
  113         _iteratorStatus = Finished;
 
  118       if (_iteratorStatus != End) {
 
  123     inline bool operator!=(
const iterator_t &it)
 const {
 
  124       return ((_iteratorStatus & it._iteratorStatus) == 0) || (_it != it._it);
 
  127     inline const iterator_t &operator++() {
 
  129         _iteratorStatus = Finished;
 
  133     inline T operator*()
 const {
 
  134       assert(_iteratorStatus != Finished);
 
  140   inline iterator_t begin() {
 
  141     return iterator_t(
this, iterator_t::Begin);
 
  144   inline iterator_t end() {
 
  145     return iterator_t(
this);
 
  149 #ifndef DOXYGEN_NOTFOR_DEVEL 
  152 template <
typename T>
 
  153 inline auto begin(Iterator<T> *it) -> decltype(it->begin()) {
 
  157 template <
typename T>
 
  158 inline auto end(Iterator<T> *it) -> decltype(it->end()) {
 
  176 template <
typename T>
 
  178   unsigned int count = 0;
 
  200 template <
typename T>
 
  202   unsigned int count = 0;
 
  205     if (count == minNbElements) {
 
  228 template <
typename T>
 
  248 template <
typename T, 
class MapFunction>
 
  250   if (
sizeof(T) > 
sizeof(
double)) {
 
  251     for (
const auto &v : it) {
 
  279 template <
typename T, 
typename reduceType, 
class ReduceFunction>
 
  281                                  ReduceFunction reduceFunction) {
 
  282   reduceType val = initVal;
 
  283   if (
sizeof(T) > 
sizeof(
double)) {
 
  284     for (
const auto &v : it) {
 
  285       val = reduceFunction(val, v);
 
  289       val = reduceFunction(val, v);
 
  308 template <
typename T>
 
  312     ret.emplace_back(std::move(it->
next()));
 
  331 template <
typename T>
 
  335     ret.emplace_back(std::move(it->
next()));
 
  354 template <
typename T>
 
  358     ret.emplace(std::move(it->
next()));
 
  364 #ifndef DOXYGEN_NOTFOR_DEVEL 
  365 template <
typename TYPE>
 
  366 class UINTIterator : 
public Iterator<TYPE> {
 
  368   UINTIterator(Iterator<unsigned int> *it) : it(it) {}
 
  369   ~UINTIterator()
 override {
 
  372   bool hasNext()
 override {
 
  373     return it->hasNext();
 
  375   TYPE next()
 override {
 
  376     return TYPE(it->next());
 
  380   Iterator<unsigned int> *it;
 
  388 #include <tulip/Edge.h> 
  389 #include <tulip/Node.h> 
reduceType iteratorReduce(Iterator< T > *it, const reduceType &initVal, ReduceFunction reduceFunction)
Reduces iterated elements to a single value.
 
bool iteratorEmpty(Iterator< T > *it)
Checks if an iterator is empty.
 
std::list< T > iteratorList(Iterator< T > *it)
Converts an iterator to a std::list.
 
std::vector< T > iteratorVector(Iterator< T > *it)
Converts an iterator to a std::vector.
 
std::set< T > iteratorSet(Iterator< T > *it)
Converts an iterator to a std::set.
 
void iteratorMap(Iterator< T > *it, MapFunction &&mapFunction)
Applies a function to each iterated element.
 
unsigned int iteratorCount(Iterator< T > *it)
Counts the number of iterated elements.
 
bool iteratorCountCheck(Iterator< T > *it, unsigned int minNbElements)
Checks a minimum amount of iterated elements.
 
Interface for Tulip iterators. Allows basic iteration operations only.
 
virtual bool hasNext()=0
Tells if the sequence is at its end.
 
virtual T next()=0
Moves the Iterator on the next element.