CASM
1.1.0
A Clusters Approach to Statistical Mechanics
|
#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 125 of file BaseCounter.hh.
Public Types | |
typedef traits< DerivedCounter >::Container | Container |
typedef traits< DerivedCounter >::value_type | value_type |
typedef traits< DerivedCounter >::size_type | size_type |
typedef traits< DerivedCounter >::Access | Access |
typedef 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 |
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 traits<DerivedCounter>::Access CASM::BaseCounter< DerivedCounter >::Access |
Definition at line 130 of file BaseCounter.hh.
typedef traits<DerivedCounter>::Compare CASM::BaseCounter< DerivedCounter >::Compare |
Definition at line 131 of file BaseCounter.hh.
typedef CounterValueIterator<DerivedCounter> CASM::BaseCounter< DerivedCounter >::const_value_iterator |
Definition at line 132 of file BaseCounter.hh.
typedef traits<DerivedCounter>::Container CASM::BaseCounter< DerivedCounter >::Container |
Definition at line 127 of file BaseCounter.hh.
typedef traits<DerivedCounter>::size_type CASM::BaseCounter< DerivedCounter >::size_type |
Definition at line 129 of file BaseCounter.hh.
typedef traits<DerivedCounter>::value_type CASM::BaseCounter< DerivedCounter >::value_type |
Definition at line 128 of file BaseCounter.hh.
|
inline |
Default construct a Counter.
Definition at line 135 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 142 of file BaseCounter.hh.
|
inlineprotected |
non-const Access the current value of the Container
Definition at line 259 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the current value of the Container
Definition at line 253 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the current value of the Container
Definition at line 244 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the final value of the Container
Definition at line 291 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the final value of the Container
Definition at line 282 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the increment value of the Container
Definition at line 307 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the increment value of the Container
Definition at line 298 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the initial value of the Container
Definition at line 275 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the initial value of the Container
Definition at line 266 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the lower value of the Container
Definition at line 341 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the lower value of the Container
Definition at line 332 of file BaseCounter.hh.
|
inlineprotected |
non-const Access to element in the upper value of the Container
Definition at line 325 of file BaseCounter.hh.
|
inlineprotected |
const Access to element in the upper value of the Container
Definition at line 316 of file BaseCounter.hh.
|
inlineprotected |
non-const reference bool validity flag
Definition at line 237 of file BaseCounter.hh.
|
inline |
Use internal Compare object to compare two values
Definition at line 193 of file BaseCounter.hh.
|
inline |
const Access the current value of the Container
Definition at line 201 of file BaseCounter.hh.
|
inline |
const Access the element 'index' of the current value of the Container
Definition at line 207 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 233 of file BaseCounter.hh.
|
inline |
const Access the intial value of the Container
Definition at line 221 of file BaseCounter.hh.
|
inline |
Definition at line 162 of file BaseCounter.hh.
|
inline |
const Access the current value of the Container (identical to current)
Definition at line 168 of file BaseCounter.hh.
|
inline |
const Access the current value of the Container (identical to current)
Definition at line 215 of file BaseCounter.hh.
|
inline |
Definition at line 170 of file BaseCounter.hh.
|
inline |
Return the size of the Container
Definition at line 178 of file BaseCounter.hh.
|
inline |
Definition at line 160 of file BaseCounter.hh.
|
inline |
Definition at line 180 of file BaseCounter.hh.
|
inline |
Definition at line 184 of file BaseCounter.hh.
|
private |
A functor that enables different ways of accessing the container, by default: container[index]
Definition at line 346 of file BaseCounter.hh.
|
private |
A functor that enables custom comparison, by default: operator<.
Definition at line 349 of file BaseCounter.hh.
|
private |
The current state of the container.
Definition at line 367 of file BaseCounter.hh.
|
private |
Final container values.
Definition at line 355 of file BaseCounter.hh.
|
private |
Amount to increment each container value.
Definition at line 358 of file BaseCounter.hh.
|
private |
Initial container values.
Definition at line 352 of file BaseCounter.hh.
|
private |
The minimum of each value of m_initial and m_final.
Definition at line 361 of file BaseCounter.hh.
|
private |
The maximum of each value of m_initial and m_final.
Definition at line 364 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 371 of file BaseCounter.hh.