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;
179 while (it->hasNext()) {
200 template <
typename T>
202 unsigned int count = 0;
203 while (it->hasNext()) {
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>
311 while (it->hasNext()) {
312 ret.emplace_back(std::move(it->next()));
331 template <
typename T>
334 while (it->hasNext()) {
335 ret.emplace_back(std::move(it->next()));
354 template <
typename T>
357 while (it->hasNext()) {
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;
383 #endif // DOXYGEN_NOTFOR_DEVEL
388 #include <tulip/Edge.h>
389 #include <tulip/Node.h>