PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 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
20template <class T>
21class cl_abstract_iterator {
22public:
23	virtual bool endp () = 0;
24	virtual T& next () = 0;
25};
26
27
28#endif /* _CL_ITERATOR_H */