node_iterator1.hpp 970 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright David Abrahams 2004. Use, modification and distribution is
  2. // subject to the Boost Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #ifndef NODE_ITERATOR1_DWA2004110_HPP
  5. # define NODE_ITERATOR1_DWA2004110_HPP
  6. # include "node.hpp"
  7. # include <boost/iterator/iterator_facade.hpp>
  8. class node_iterator
  9. : public boost::iterator_facade<
  10. node_iterator
  11. , node_base
  12. , boost::forward_traversal_tag
  13. >
  14. {
  15. public:
  16. node_iterator()
  17. : m_node(0)
  18. {}
  19. explicit node_iterator(node_base* p)
  20. : m_node(p)
  21. {}
  22. private:
  23. friend class boost::iterator_core_access;
  24. void increment()
  25. { m_node = m_node->next(); }
  26. bool equal(node_iterator const& other) const
  27. { return this->m_node == other.m_node; }
  28. node_base& dereference() const
  29. { return *m_node; }
  30. node_base* m_node;
  31. };
  32. #endif // NODE_ITERATOR1_DWA2004110_HPP