PolyBoRi
CTermIter.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
13 //*****************************************************************************
14 
15 #ifndef polybori_iterators_CTermIter_h_
16 #define polybori_iterators_CTermIter_h_
17 
18 // include basic definitions
19 #include <polybori/pbori_defs.h>
20 
21 // include polybori functionals
23 
24 // include polybori properties
25 #include <polybori/common/traits.h>
26 
27 
28 // include boost's interator facade
29 #include <boost/iterator/iterator_facade.hpp>
30 
31 #include <polybori/BooleEnv.h>
32 
33 
35 
36 
43 template <class StackType, class TermGeneratorType>
44 class CTermIter:
45  public boost::iterator_facade<
46  CTermIter<StackType, TermGeneratorType>,
47  typename TermGeneratorType::value_type,
48  typename StackType::iterator_category,
49  typename TermGeneratorType::result_type
50  > {
51 
52 public:
53 
55  typedef StackType stack_type;
56 
58  typedef typename stack_type::navigator navigator;
59 
61  typedef typename navigator::idx_type idx_type;
62 
64  typedef typename navigator::bool_type bool_type;
65 
67  typedef typename navigator::size_type size_type;
68 
70  typedef typename navigator::deg_type deg_type;
71 
73  typedef TermGeneratorType term_generator;
74 
76 
77  typedef typename stack_type::const_iterator const_iterator;
78  typedef typename stack_type::const_reverse_iterator
81 
83  CTermIter(const CTermIter& rhs):
84  m_getTerm(rhs.m_getTerm), m_stack(rhs.m_stack) {
85  }
86 
88  template <class MgrType>
89  CTermIter(navigator navi, const MgrType& mgr):
90  m_getTerm(mgr), m_stack(navi, mgr) {
91  m_stack.init();
92  }
93 
96 
98  void increment() {
99  m_stack.increment();
100  }
101 
103  void decrement() {
104  m_stack.decrement();
105  }
106 
108  bool_type equal (const CTermIter& rhs) const {
109  return m_stack.equal(rhs.m_stack);
110  }
111 
113  typename term_generator::result_type dereference() const {
114  return m_getTerm(m_stack);
115  }
116 
118 
119  const_iterator begin() const { return m_stack.begin(); }
120  const_iterator end() const { return m_stack.end(); }
121  const_reverse_iterator rbegin() const { return m_stack.rbegin(); }
122  const_reverse_iterator rend() const { return m_stack.rend(); }
124 
126  bool_type isOne() const { return m_stack.isOne(); }
127 
129  bool_type isZero() const { return m_stack.isZero(); }
130 
132  bool_type isEnd() const { return isZero(); }
133 
135  deg_type deg() const { return m_stack.deg(); }
136 
138  idx_type firstIndex() const {
139  PBORI_ASSERT(!m_stack.empty());
140  return *begin();
141  }
142 
145  return m_stack.navigation();
146  }
147 
148 protected:
151 
154 };
155 
156 
158 
159 #endif
160