PageRenderTime 40ms CodeModel.GetById 15ms 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. #ifndef _CL_ITERATOR_H
  3. #define _CL_ITERATOR_H
  4. #include "cln/types.h"
  5. // An iterator's typical use is a loop, but you have an abstraction over
  6. // the loop's initialization, step and end-test.
  7. // Example:
  8. // foo_iterator foo_loop = ...;
  9. // while (!foo_loop.endp()) {
  10. // foo element = foo_loop.next();
  11. // ...
  12. // }
  13. // It is allowed to call endp() as many times as you want, and to terminate
  14. // the loop any time you want.
  15. template <class T>
  16. class cl_abstract_iterator {
  17. public:
  18. virtual bool endp () = 0;
  19. virtual T& next () = 0;
  20. };
  21. #endif /* _CL_ITERATOR_H */