You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
610 B

25 years ago
25 years ago
  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 */