14 template<
typename _Container,
typename _value_type,
typename _
size_type,
typename _Access,
typename _Compare>
66 template<
typename _Container,
typename _value_type,
typename _
size_type,
typename _Access,
typename _Compare>
77 template <
typename _Container,
78 typename _value_type =
typename _Container::value_type,
79 typename _size_type =
typename _Container::size_type,
82 class IsoCounter :
public BaseCounter<IsoCounter<_Container, _value_type, _size_type, _Access, _Compare> > {
87 using Base::_increment;
104 using Base::operator();
105 using Base::operator[];
106 using Base::operator bool;
121 const value_type &_sum,
122 Access _access =
Access(),
123 Compare _compare =
Compare()) :
124 Base(_initial, _final,
Array<value_type>(1, _increment), _access, _compare),
m_sum_constraint(_sum) {
137 for(size_type i = 1; i <
size(); i++) {
150 size_type i(0), j(0);
151 bool continue_flag =
valid();
152 value_type next_i, next_j;
153 for(i = 0; i + 1 <
size(); i++) {
172 continue_flag =
false;
178 if(continue_flag || !
valid()) {
222 std::cerr <<
"CRITICAL ERROR: In IsoCounter::set_current(), new state is incompatible with this counter.\n"
248 for(i = 0; i <
size(); i++) {
285 for(size_type i = 0; i <
size() &&
valid(); i++) {
295 for(size_type i = 0; i <
initial().size(); i++) {
308 return Base::_increment(0);
312 return Base::_increment(0);
const value_type & _final(size_type index) const
const Container & current() const
bool almost_zero(const T &val, double tol=TOL)
If T is not integral, use std::abs(val) < tol;.
IsoCounter()
Default construct a IsoCounter Container must be default constructible value_type must be constructib...
bool compare(const T &A, const T &B, double tol)
Floating point comparison with tol, return A < B.
value_type m_sum_constraint
BaseCounter< IsoCounter< _Container, _value_type, _size_type, _Access, _Compare > > Base
const value_type & increment() const
void reset()
Reset thse current value of the Counter to the initial value.
const value_type & _upper(size_type index) const
value_type current_sum() const
bool & _valid()
non-const reference bool validity flag
void set_current(const Container &new_current)
A Counter allows looping over many incrementing variables in one loop.
value_type & _increment()
value_type & _sum_constraint()
IsoCounter(const Container &_initial, const Container &_final, const value_type &_increment, const value_type &_sum, Access _access=Access(), Compare _compare=Compare())
Construct a IsoCounter-type object.
Helper Functor for Counter container access using operator[].
const value_type & _sum_constraint() const
A IsoCounter allows looping over many incrementing variables in one loop.
void set_sum_constraint(const value_type &new_sum)
const value_type & _initial(size_type index) const
const value_type & _increment() const
CASM_TMP::traits< IsoCounter >::Base Base
IsoCounter & operator++()
const Container & initial() const
bool compare(const value_type &A, const value_type &B)
void _init()
Called from the constructor to set m_lower and m_upper appropriately.
const value_type & _lower(size_type index) const
typename std::conditional< boost::is_integral< T >::value, IntegralLessThan< T >, FloatingPointLessThan< T > >::type MuchLessThan
Basic std::vector like container (deprecated)