CTermIter.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_iterators_CTermIter_h_
#define polybori_iterators_CTermIter_h_
// include basic definitions
#include <polybori/pbori_defs.h>
// include polybori functionals
#include <polybori/routines/pbori_func.h>
// include polybori properties
#include <polybori/common/traits.h>
// include boost's interator facade
#include <boost/iterator/iterator_facade.hpp>
#include <polybori/BooleEnv.h>
BEGIN_NAMESPACE_PBORI
template <class StackType, class TermGeneratorType>
class CTermIter:
public boost::iterator_facade<
CTermIter<StackType, TermGeneratorType>,
typename TermGeneratorType::value_type,
typename StackType::iterator_category,
typename TermGeneratorType::result_type
> {
public:
typedef StackType stack_type;
typedef typename stack_type::navigator navigator;
typedef typename navigator::idx_type idx_type;
typedef typename navigator::bool_type bool_type;
typedef typename navigator::size_type size_type;
typedef typename navigator::deg_type deg_type;
typedef TermGeneratorType term_generator;
typedef typename stack_type::const_iterator const_iterator;
typedef typename stack_type::const_reverse_iterator
const_reverse_iterator;
CTermIter(const CTermIter& rhs):
m_getTerm(rhs.m_getTerm), m_stack(rhs.m_stack) {
}
template <class MgrType>
CTermIter(navigator navi, const MgrType& mgr):
m_getTerm(mgr), m_stack(navi, mgr) {
m_stack.init();
}
~CTermIter() {}
void increment() {
m_stack.increment();
}
void decrement() {
m_stack.decrement();
}
bool_type equal (const CTermIter& rhs) const {
return m_stack.equal(rhs.m_stack);
}
typename term_generator::result_type dereference() const {
return m_getTerm(m_stack);
}
const_iterator begin() const { return m_stack.begin(); }
const_iterator end() const { return m_stack.end(); }
const_reverse_iterator rbegin() const { return m_stack.rbegin(); }
const_reverse_iterator rend() const { return m_stack.rend(); }
bool_type isOne() const { return m_stack.isOne(); }
bool_type isZero() const { return m_stack.isZero(); }
bool_type isEnd() const { return isZero(); }
deg_type deg() const { return m_stack.deg(); }
idx_type firstIndex() const {
PBORI_ASSERT(!m_stack.empty());
return *begin();
}
navigator navigation() const {
return m_stack.navigation();
}
protected:
term_generator m_getTerm;
stack_type m_stack;
};
END_NAMESPACE_PBORI
#endif