20 #ifndef Tulip_FOREACH_H
21 #define Tulip_FOREACH_H
24 #include <tulip/Iterator.h>
25 #include <tulip/StableIterator.h>
26 #include <tulip/tulipconf.h>
28 #ifndef DOXYGEN_NOTFOR_DEVEL
35 template<
typename TYPE>
37 _TLP_IT(Iterator<TYPE> *_it) : _it(_it) {
48 template<
typename TYPE>
50 assert(_it._it != NULL);
52 if(_it._it->hasNext()) {
61 #endif //DOXYGEN_NOTFOR_DEVEL
77 #define forEach(A, B) \
78 for(tlp::_TLP_IT<TYPEOF(A) > _it_foreach(B); tlp::_tlp_if_test(A, _it_foreach);)
86 #define stableForEach(A, B) \
87 for(tlp::_TLP_IT<TYPEOF(A) > _it_foreach(new StableIterator<TYPEOF(A) >(B)); tlp::_tlp_if_test(A, _it_foreach);)
89 #if defined(__GXX_EXPERIMENTAL_CXX0X__)
100 iterator_t(tlp::Iterator<T>* it, IteratorType begin = End) : _finished(false), _iteratorType(begin), _it(it) {
101 if(_iteratorType == Begin) {
103 _current = _it->next();
112 if(_iteratorType == Begin) {
117 bool operator!=(
const iterator_t&)
const {
121 const iterator_t& operator++() {
122 _finished = !_it->hasNext();
125 _current = _it->next();
130 T operator*()
const {
136 IteratorType _iteratorType;
137 tlp::Iterator<T>* _it;
142 iterator_t<T> begin(tlp::Iterator<T>* it) {
143 return iterator_t<T>(it, iterator_t<T>::Begin);
147 iterator_t<T> end(tlp::Iterator<T>* it) {
148 return iterator_t<T>(it);
152 #endif //__GXX_EXPERIMENTAL_CXX0X__
Encapsulation of a Tulip Iterator intended to be allocated on the stack instead of the heap...