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 
144  navigator navigation() const {
145  return m_stack.navigation();
146  }
147 
148 protected:
150  term_generator m_getTerm;
151 
153  stack_type m_stack;
154 };
155 
156 
158 
159 #endif
160 
#define END_NAMESPACE_PBORI
Finish project's namespace.
Definition: pbori_defs.h:77
#define BEGIN_NAMESPACE_PBORI
Start project's namespace.
Definition: pbori_defs.h:74
void increment()
Incrementation operation.
Definition: CTermIter.h:98
StackType stack_type
Define type for storing current path (term) in stack of nodes.
Definition: CTermIter.h:55
int deg_type
Definition: groebner_defs.h:42
bool_type isEnd() const
Check, whether end of iteration is reached.
Definition: CTermIter.h:132
CTermIter(const CTermIter &rhs)
Copy constructor.
Definition: CTermIter.h:83
stack_type m_stack
The stack, which carries the current path.
Definition: CTermIter.h:153
bool_type isZero() const
Determine whether term is zero (without explicit constructing)
Definition: CTermIter.h:129
navigator navigation() const
Get navigator of term start.
Definition: CTermIter.h:144
idx_type firstIndex() const
Get first index of current term.
Definition: CTermIter.h:138
deg_type deg() const
Get degree of current term.
Definition: CTermIter.h:135
navigator::size_type size_type
Type for lengths.
Definition: CTermIter.h:67
~CTermIter()
Destructor.
Definition: CTermIter.h:95
navigator::idx_type idx_type
Type for indices.
Definition: CTermIter.h:61
This class defines an iterator for the monomials in a Boolean polynomial.
Definition: CTermIter.h:44
stack_type::navigator navigator
Get type of navigators.
Definition: CTermIter.h:58
#define PBORI_ASSERT(arg)
Definition: pbori_defs.h:118
bool_type equal(const CTermIter &rhs) const
Equality test.
Definition: CTermIter.h:108
navigator::bool_type bool_type
Type for Boolean results.
Definition: CTermIter.h:64
term_generator m_getTerm
The functional which defines the dereferecing operation.
Definition: CTermIter.h:150
const_iterator end() const
Definition: CTermIter.h:120
void decrement()
Decrementation operation.
Definition: CTermIter.h:103
const_reverse_iterator rbegin() const
Definition: CTermIter.h:121
CTermIter(navigator navi, const MgrType &mgr)
Construct from navigator over decision diagram.
Definition: CTermIter.h:89
term_generator::result_type dereference() const
Dereferencing of the iterator.
Definition: CTermIter.h:113
polybori::CTypes::idx_type idx_type
Definition: groebner_defs.h:44
TermGeneratorType term_generator
Type for functional, which generates actual term, for current path.
Definition: CTermIter.h:73
navigator::deg_type deg_type
Type for degrees.
Definition: CTermIter.h:70
const_reverse_iterator rend() const
Definition: CTermIter.h:122
bool_type isOne() const
Determine whether term is one (without explicit constructing)
Definition: CTermIter.h:126
stack_type::const_iterator const_iterator
Definition: CTermIter.h:77
stack_type::const_reverse_iterator const_reverse_iterator
Definition: CTermIter.h:79
const_iterator begin() const
Definition: CTermIter.h:119