• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 # include "node.hpp"
8 # include <boost/iterator/iterator_facade.hpp>
9 
10 class node_iterator
11   : public boost::iterator_facade<
12         node_iterator
13       , node_base
14       , boost::forward_traversal_tag
15     >
16 {
17  public:
node_iterator()18     node_iterator()
19       : m_node(0)
20     {}
21 
node_iterator(node_base * p)22     explicit node_iterator(node_base* p)
23       : m_node(p)
24     {}
25 
26  private:
27     friend class boost::iterator_core_access;
28 
increment()29     void increment()
30     { m_node = m_node->next(); }
31 
equal(node_iterator const & other) const32     bool equal(node_iterator const& other) const
33     { return this->m_node == other.m_node; }
34 
dereference() const35     node_base& dereference() const
36     { return *m_node; }
37 
38     node_base* m_node;
39 };
40 
41 
42 #endif // NODE_ITERATOR1_DWA2004110_HPP
43