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> 35 template<
typename TYPE>
48 template<
typename TYPE>
49 inline bool _tlp_if_test(TYPE &n, _TLP_IT<TYPE> &_it) {
50 assert(_it._it != NULL);
52 if(_it._it->hasNext()) {
77 #define forEach(A, B) \ 78 for(tlp::_TLP_IT<TLP_TYPEOF(A) > _it_foreach(B); tlp::_tlp_if_test(A, _it_foreach);) 86 #define stableForEach(A, B) \ 87 for(tlp::_TLP_IT<TLP_TYPEOF(A) > _it_foreach(new tlp::StableIterator<TLP_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__