]> www.ginac.de Git - cln.git/blob - src/base/cl_iterator.h
* src/base/cl_macros.h: alloca(3) has size_t argument type.
[cln.git] / src / base / cl_iterator.h
1 // Abstract iterators.
2
3 #ifndef _CL_ITERATOR_H
4 #define _CL_ITERATOR_H
5
6 #include "cln/types.h"
7
8
9 // An iterator's typical use is a loop, but you have an abstraction over
10 // the loop's initialization, step and end-test.
11 // Example:
12 //    foo_iterator foo_loop = ...;
13 //    while (!foo_loop.endp()) {
14 //        foo element = foo_loop.next();
15 //        ...
16 //    }
17 // It is allowed to call endp() as many times as you want, and to terminate
18 // the loop any time you want.
19
20 template <class T>
21 class cl_abstract_iterator {
22 public:
23         virtual bool endp () = 0;
24         virtual T& next () = 0;
25 };
26
27
28 #endif /* _CL_ITERATOR_H */