/usr/include/polybori/CBidirectTermIter.h is in libpolybori-dev 0.5~rc1-2.1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | // -*- c++ -*-
//*****************************************************************************
/** @file CBidirectTermIter.h
*
* @author Alexander Dreyer
* @date 2006-04-21
*
*
*
* @par Copyright:
* (c) 2006 by The PolyBoRi Team
*
* @internal
* @version \$Id: CBidirectTermIter.h,v 1.9 2008/07/08 21:41:58 alexanderdreyer Exp $
*
* @par History:
* @verbatim
* $Log: CBidirectTermIter.h,v $
* Revision 1.9 2008/07/08 21:41:58 alexanderdreyer
* Merge: from developer's repository
*
* Revision 1.6 2007/11/06 15:03:33 dreyer
* CHANGE: More generic copyright
*
* Revision 1.5 2007/05/03 16:04:45 dreyer
* CHANGE: new-style CTermIter integrated
*
* Revision 1.4 2007/04/18 15:37:28 dreyer
* ADD: dp_asc now active
*
* Revision 1.3 2006/09/13 15:07:04 dreyer
* ADD: lead(sugar) and infrastructure
*
* Revision 1.2 2006/09/12 14:56:55 dreyer
* ADD bidirectional term iterator template
*
* Revision 1.1 2006/09/12 13:48:41 dreyer
* + Initial Version
*
* @endverbatim
**/
//*****************************************************************************
// get standard header
#include <stack>
#include <utility>
// include basic definitions
#include "pbori_defs.h"
// Get forward term iterator
#include "CTermIter.h"
#ifndef CBidirectTermIter_h_
#define CBidirectTermIter_h_
BEGIN_NAMESPACE_PBORI
template<class NavigatorType>
class handle_else :
public std::deque<NavigatorType> {
public:
typedef NavigatorType navigator_type;
typedef std::deque<NavigatorType> base;
void operator()(const navigator_type& navi) {
while(!base::empty() && (*top() >= *navi) )
base::pop_back();
base::push_back(navi);
}
void push(const navigator_type& navi) { base::push_back(navi); }
void pop() { base::pop_back(); }
const navigator_type& top() const { return base::back(); };
void append(const handle_else& rhs) {
assert(base::empty() || rhs.empty() || ((**rhs.begin()) > (*top())) );
base::insert(base::end(), rhs.begin(), rhs.end());
}
};
#if 0
/** @class CBidirectTermIter
* @brief This class defines an iterator for the monomials in a Boolean
* polynomial.
*
**/
template <class TermType, class NavigatorType,
class ForwardOp, class BackwardOp,
class TerminalValueOp = project_ith<2> >
class CBidirectTermIter:
public CTermIter<TermType, NavigatorType,
ForwardOp, BackwardOp,
TerminalValueOp,
handle_else<NavigatorType> >{
public:
/// Type for boolean results
typedef TermType term_type;
/// Get type of navigators
typedef NavigatorType navigator_type;
/// Get operational, which changes the current term on forward steps
typedef ForwardOp forwardop_type;
/// Get operational, which changes the current term on backward steps
typedef BackwardOp backwardop_type;
/// Get operational, which generates terminal value corresponding to Boolean
typedef TerminalValueOp termvalop_type;
/// Type, which stacks else banches.
typedef handle_else<navigator_type> elsehandle_type;
/// Get type of *this
typedef CBidirectTermIter<term_type, navigator_type,
forwardop_type, backwardop_type, termvalop_type> self;
/// Generic access to base type;
typedef CTermIter<term_type, navigator_type,
forwardop_type, backwardop_type, termvalop_type,
elsehandle_type> base;
/// @name Interface types for standard iterator access
//@{
typedef std::bidirectional_iterator_tag iterator_category;
typedef typename base::difference_type difference_type;
typedef typename base::pointer pointer;
typedef typename base::reference reference;
//@}
/// Generic access to member
using base::handleElse;
/// Default constructor
CBidirectTermIter():
base() {}
/// Construct from initial navigator
CBidirectTermIter(navigator_type navi,
forwardop_type fop_ = forwardop_type(),
backwardop_type bop_ = backwardop_type(),
termvalop_type tvop_ = termvalop_type() ):
base(navi, fop_, bop_, tvop_) {}
/// Construct last term from initial navigator
CBidirectTermIter(navigator_type navi, dummy_iterator):
base() {
if(navi.isValid()) {
followElse(navi);
terminate(navi);
}
}
/// Copy Constructor
CBidirectTermIter(const self& rhs):
base(rhs) {};
/// Destructor
~CBidirectTermIter() {};
/// Prefix increment operator
self& operator++() {
base::operator++();
return *this;
}
/// Postfix increment operator
self operator++(int dummy) {
return base::operator++(dummy);
};
/// Prefix decrement operator
self& operator--() {
if (!handleElse.empty()){
navigator_type navi = handleElse.top();
base::popToIndex(*navi);
handleElse.pop();
base::nextThen(navi);
followElse(navi);
}
else
base::clear();
return *this;
}
/// Postfix decrement operator
self operator--(int) {
self tmp(*this);
operator--();
return tmp;
};
protected:
void followElse(navigator_type& navi) {
while( !navi.isConstant() ) { // if still in interior of a path
if(!navi.elseBranch().isEmpty()) {
handleElse.push(navi);
navi.incrementElse(); // go in direction of last term, if possible
}
else
base::nextThen(navi);
}
}
};
#endif
END_NAMESPACE_PBORI
#endif
|