CCuddFirstIter.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_iterators_CCuddFirstIter_h_
#define polybori_iterators_CCuddFirstIter_h_
// include basic definitions
#include "CCuddNavigator.h"
// include boost's interator facade
#include <boost/iterator/iterator_facade.hpp>
BEGIN_NAMESPACE_PBORI
class CCuddFirstIter :
public boost::iterator_facade<
CCuddFirstIter,
CCuddNavigator::value_type,
std::forward_iterator_tag,
CCuddNavigator::reference
> {
public:
typedef std::forward_iterator_tag iterator_category;
typedef CCuddFirstIter self;
typedef CCuddNavigator navigator;
typedef navigator::const_access_type const_access_type;
typedef navigator::bool_type bool_type;
CCuddFirstIter(): m_navi() {}
CCuddFirstIter(navigator rhs): m_navi(rhs) { terminateConstant(); }
~CCuddFirstIter() {}
void increment() {
m_navi.incrementThen();
terminateConstant();
}
bool_type equal (const self& rhs) const { return (m_navi == rhs.m_navi); }
navigator::reference dereference() const { return *m_navi; }
bool_type isEnd() const { return !m_navi.isValid(); }
protected:
void terminateConstant() {
if (m_navi.isConstant())
*this = self(); // mark end of path reached
}
navigator m_navi;
};
END_NAMESPACE_PBORI
#endif