CASM
AClustersApproachtoStatisticalMechanics
|
#include <BaseCounter.hh>
A Counter allows looping over many incrementing variables in one loop.
Container | The type of container containing the variables begin looped over. Container should be fully specified, so 'std::vector<int>', not 'std::vector'. |
value_type | The type of variable contained by the Container. Must have valid operators '+=' and '+'. |
size_type | The type of the index into the Container. |
Access | A Functor or function with signature 'value_type& Access::operator()(Container &, size_type);', which provides a reference to a element of the Container. |
Default container access using the CASM_TMP::BracketAccess functor is identical to 'container[index]'. Parentheses access, like 'container(index)', can be obtained by setting the Access parameter using the CASM_TMP::ParenthesesAccess functor.
Default value_type comparison is as 'value_type < value_type'. Custom comparison can be provided using the Compare functor.
Several typedefs are provided:
The first element of the container is the inner loop, and the last element of the container is the outer loop.
Example:
Output:
Definition at line 114 of file BaseCounter.hh.
Public Types | |
typedef CASM_TMP::traits < DerivedCounter >::Container | Container |
typedef CASM_TMP::traits < DerivedCounter >::value_type | value_type |
typedef CASM_TMP::traits < DerivedCounter >::size_type | size_type |
typedef CASM_TMP::traits < DerivedCounter >::Access | Access |
typedef CASM_TMP::traits < DerivedCounter >::Compare | Compare |
typedef CounterValueIterator < DerivedCounter > | const_value_iterator |
Public Member Functions | |
BaseCounter () | |
Default construct a Counter. More... | |
BaseCounter (const Container &_initial, const Container &_final, const Container &_increment, Access _access=Access(), Compare _compare=Compare()) | |
Construct a Counter-type object. More... | |
bool | valid () const |
operator bool () const | |
operator const Container & () const | |
const value_type & | operator[] (size_type index) const |
size_type | size () const |
const_value_iterator | value_begin () const |
const_value_iterator | value_end () const |
bool | compare (const value_type &A, const value_type &B) |
const Container & | current () const |
const value_type & | current (size_type index) const |
const Container & | operator() () const |
const Container & | initial () const |
const Container & | final () const |
const Container & | increment () const |
Protected Member Functions | |
bool & | _valid () |
non-const reference bool validity flag More... | |
const value_type & | _current (size_type index) const |
value_type & | _current (size_type index) |
Container & | _current () |
const value_type & | _initial (size_type index) const |
value_type & | _initial (size_type index) |
const value_type & | _final (size_type index) const |
value_type & | _final (size_type index) |
const value_type & | _increment (size_type index) const |
value_type & | _increment (size_type index) |
const value_type & | _upper (size_type index) const |
value_type & | _upper (size_type index) |
const value_type & | _lower (size_type index) const |
value_type & | _lower (size_type index) |
Private Attributes | |
Access | m_access |
A functor that enables different ways of accessing the container, by default: container[index]. More... | |
Compare | m_compare |
A functor that enables custom comparison, by default: operator<. More... | |
Container | m_initial |
Initial container values. More... | |
Container | m_final |
Final container values. More... | |
Container | m_increment |
Amount to increment each container value. More... | |
Container | m_lower |
The minimum of each value of m_initial and m_final. More... | |
Container | m_upper |
The maximum of each value of m_initial and m_final. More... | |
Container | m_current |
The current state of the container. More... | |
bool | m_valid |
typedef CASM_TMP::traits<DerivedCounter>::Access CASM::BaseCounter< DerivedCounter >::Access |
Definition at line 120 of file BaseCounter.hh.
typedef CASM_TMP::traits<DerivedCounter>::Compare CASM::BaseCounter< DerivedCounter >::Compare |
Definition at line 121 of file BaseCounter.hh.
typedef CounterValueIterator<DerivedCounter> CASM::BaseCounter< DerivedCounter >::const_value_iterator |
Definition at line 122 of file BaseCounter.hh.
typedef CASM_TMP::traits<DerivedCounter>::Container CASM::BaseCounter< DerivedCounter >::Container |
Definition at line 117 of file BaseCounter.hh.
typedef CASM_TMP::traits<DerivedCounter>::size_type CASM::BaseCounter< DerivedCounter >::size_type |
Definition at line 119 of file BaseCounter.hh.
typedef CASM_TMP::traits<DerivedCounter>::value_type CASM::BaseCounter< DerivedCounter >::value_type |
Definition at line 118 of file BaseCounter.hh.
|
inline |
Default construct a Counter.
Definition at line 125 of file BaseCounter.hh.
|
inline |
Construct a Counter-type object.
_initial | the initial Container values |
_final | the final valid Container values |
_increment | the amount to increment each Container value by |
Definition at line 133 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the current value of the Container
Definition at line 250 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the current value of the Container
Definition at line 258 of file BaseCounter.hh.
|
inlineprotected |
non-const Access the current value of the Container
Definition at line 267 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the final value of the Container
Definition at line 291 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the final value of the Container
Definition at line 299 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the increment value of the Container
Definition at line 307 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the increment value of the Container
Definition at line 315 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the initial value of the Container
Definition at line 275 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the initial value of the Container
Definition at line 283 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the lower value of the Container
Definition at line 339 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the lower value of the Container
Definition at line 347 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the upper value of the Container
Definition at line 323 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the upper value of the Container
Definition at line 331 of file BaseCounter.hh.
|
inlineprotected |
non-const reference bool validity flag
Definition at line 241 of file BaseCounter.hh.
|
inline |
Use internal Compare object to compare two values
Definition at line 187 of file BaseCounter.hh.
|
inline |
const Access the current value of the Container
Definition at line 195 of file BaseCounter.hh.
|
inline |
const Access the element 'index' of the current value of the Container
Definition at line 203 of file BaseCounter.hh.
|
inline |
const Access the final value of the Container
Definition at line 227 of file BaseCounter.hh.
|
inline |
const Access the incrementing values of the Container
Definition at line 235 of file BaseCounter.hh.
|
inline |
const Access the intial value of the Container
Definition at line 219 of file BaseCounter.hh.
|
inline |
Definition at line 150 of file BaseCounter.hh.
|
inline |
const Access the current value of the Container (identical to current)
Definition at line 158 of file BaseCounter.hh.
|
inline |
const Access the current value of the Container (identical to current)
Definition at line 211 of file BaseCounter.hh.
|
inline |
Definition at line 163 of file BaseCounter.hh.
|
inline |
Return the size of the Container
Definition at line 171 of file BaseCounter.hh.
|
inline |
Definition at line 146 of file BaseCounter.hh.
|
inline |
Definition at line 175 of file BaseCounter.hh.
|
inline |
Definition at line 179 of file BaseCounter.hh.
|
private |
A functor that enables different ways of accessing the container, by default: container[index].
Definition at line 353 of file BaseCounter.hh.
|
private |
A functor that enables custom comparison, by default: operator<.
Definition at line 356 of file BaseCounter.hh.
|
private |
The current state of the container.
Definition at line 374 of file BaseCounter.hh.
|
private |
Final container values.
Definition at line 362 of file BaseCounter.hh.
|
private |
Amount to increment each container value.
Definition at line 365 of file BaseCounter.hh.
|
private |
Initial container values.
Definition at line 359 of file BaseCounter.hh.
|
private |
The minimum of each value of m_initial and m_final.
Definition at line 368 of file BaseCounter.hh.
|
private |
The maximum of each value of m_initial and m_final.
Definition at line 371 of file BaseCounter.hh.
|
private |
True if m_current is within the allowed bounds, false once all values have been incremented to their limit
Definition at line 378 of file BaseCounter.hh.