4 #include <boost/iterator/iterator_facade.hpp> 5 #include <boost/operators.hpp> 10 template<
class T>
class poly;
16 boost::incrementable< poly<T>,
17 boost::addable< poly<T>,
18 boost::multipliable< poly<T>,
19 boost::multipliable2< poly<T>, T,
20 boost::less_than_comparable< poly<T> > > > > > {
34 const_column_iterator column(columns.begin()), Rcolumn(R.
columns.begin());
35 while( column!=columns.end() && Rcolumn!=R.
columns.end() && *column==*Rcolumn) { ++column; ++Rcolumn; }
36 return column!=columns.end() && Rcolumn!=R.
columns.end() && *column < *Rcolumn;
53 if(columns.empty())
return 0;
55 for( const_column_iterator column = columns.begin(); column != columns.end(); ++column)
56 size *= column->size();
61 :
public boost::iterator_facade< const_iterator, T const, boost::bidirectional_traversal_tag, T > {
64 std::list<typename std::set<T>::const_iterator>
state;
67 typedef typename std::list<typename std::set<T>::const_iterator>::iterator
state_iterator;
71 T dereference()
const {
T s;
for(const_state_iterator istate=state.begin(); istate!=state.end(); ++istate) s+= **istate;
return s; }
73 state_iterator istate = state.begin();
74 const_column_iterator column =
begin;
75 while( column != end && ++*istate == column->end() ) { ++istate; ++column;}
76 if( column == end ) {--column; --istate;}
77 while( istate != state.begin() ) {--istate; *istate = (--column)->
begin();}
80 state_iterator istate = state.begin();
81 const_column_iterator column =
begin;
82 while( column != end && *istate == column->begin()) { ++istate; ++column;}
83 if( column != end) --*istate;
84 while( istate != state.begin() ) {--istate; *istate = --((--column)->
end());}
91 const_column_iterator column =
begin;
92 while(column!=end) state.push_back((column++)->
begin());
107 template <
class charT,
class traits,
class T>
109 std::basic_ostream<charT,traits>& operator<<(std::basic_ostream<charT,traits>& strm,
const poly<T>&
f) {
110 for(
auto const& column :
f.getColumns())
111 { strm <<
"( ";
for(
auto const&
entry : column) strm <<
entry <<
", "; strm <<
" )" << std::endl; }
const_iterator(const poly &p)
const_iterator end() const
auto const & getColumns() const
poly operator*=(const T &r)
std::list< std::set< T > >::const_iterator begin
friend poly< T > operator+(const poly< T > &, const char *)
std::list< typename std::set< T >::const_iterator > state
poly operator+=(const poly &R)
bool equal(const T &first, const T &second)
const_iterator begin() const
bool equal(const_iterator const &rhs) const
std::list< std::set< T > > columns
std::list< typename std::set< T >::const_iterator >::const_iterator const_state_iterator
std::list< std::set< T > >::const_iterator const_column_iterator
std::list< typename std::set< T >::const_iterator >::iterator state_iterator
static const_iterator end_of(const poly &p)
bool operator<(const poly &R) const
poly< T > operator+(const poly< T > &, const char *)
friend class boost::iterator_core_access
std::list< std::set< T > >::iterator column_iterator
poly operator*=(const poly &R)
poly operator+=(const T &r)
std::list< std::set< T > >::const_iterator end