/cln-1.3.2/src/base/cl_iterator.h
C Header | 28 lines | 10 code | 7 blank | 11 comment | 0 complexity | daa9958a681c13c35f2e0557dea84f59 MD5 | raw file
Possible License(s): GPL-2.0
- // Abstract iterators.
- #ifndef _CL_ITERATOR_H
- #define _CL_ITERATOR_H
- #include "cln/types.h"
- // An iterator's typical use is a loop, but you have an abstraction over
- // the loop's initialization, step and end-test.
- // Example:
- // foo_iterator foo_loop = ...;
- // while (!foo_loop.endp()) {
- // foo element = foo_loop.next();
- // ...
- // }
- // It is allowed to call endp() as many times as you want, and to terminate
- // the loop any time you want.
- template <class T>
- class cl_abstract_iterator {
- public:
- virtual bool endp () = 0;
- virtual T& next () = 0;
- };
- #endif /* _CL_ITERATOR_H */