ModErn Text Analysis
META Enumerates Textual Applications
node_iterator.h
Go to the documentation of this file.
1 
10 template <class Iter>
11 class node_iterator : public std::iterator<std::forward_iterator_tag, Node>
12 {
13  public:
14  typedef std::vector<std::pair<Node, adjacency_list>> vec_t;
15  typedef node_iterator self_type;
16  typedef typename std::conditional<
17  std::is_same<Iter, typename vec_t::const_iterator>::value,
18  const Node,
19  Node>::type value_type;
20  typedef value_type* pointer;
21  typedef value_type& reference;
22  typedef std::forward_iterator_tag iterator_category;
23  typedef ptrdiff_t difference_type;
24 
25  friend bool operator==(const self_type& lhs, const self_type& rhs)
26  {
27  return lhs.iter_ == rhs.iter_;
28  }
29 
30  friend bool operator!=(const self_type& lhs, const self_type& rhs)
31  {
32  return !(lhs == rhs);
33  }
34 
35  node_iterator(const Iter& iter) : iter_{iter} {}
36 
37  self_type operator++()
38  {
39  ++iter_;
40  return *this;
41  }
42 
43  self_type operator++(int)
44  {
45  self_type saved{*this};
46  ++(*this);
47  return saved;
48  }
49 
50  reference operator*() { return iter_->first; }
51 
52  pointer operator->() { return &iter_->first; }
53 
54  private:
55  Iter iter_;
56 };
Definition: node_iterator.h:11