|
cisst-saw
|
#include <nmrMultiIndexCounter.h>
Public Types | |
| enum | CounterStatus { COUNTER_UNDERFLOW = -1 , COUNTER_IN_BOUNDS = 0 , COUNTER_OVERFLOW = 1 , COUNTER_UNDEFINED = 2 } |
| typedef int | IndexType |
Public Member Functions | |
| nmrMultiIndexCounter (unsigned int size) | |
| void | SetAllIncrements (IndexType increment) |
| unsigned int | GetSize () const |
| void | SetBounds (const IndexType lowBounds[], const IndexType highBounds[]) |
| void | SetLowBound (unsigned int counter, IndexType bound) |
| void | SetHighBound (unsigned int counter, IndexType bound) |
| void | SetIncrements (const IndexType increments[]) |
| void | SetIncrement (unsigned int counter, IndexType increment) |
| IndexType | operator[] (unsigned int i) const |
| const IndexType * | GetIndexCells () const |
| const unsigned int * | GetIndexCellsAsUnsigned () const |
| const IndexType * | GetLowBounds () const |
| IndexType | GetLowBound (unsigned int counter) const |
| const IndexType * | GetHighBounds () const |
| IndexType | GetHighBound (unsigned int counter) const |
| const IndexType * | GetIncrements () const |
| IndexType | GetIncrement (unsigned int counter) const |
| void | SetIndex (unsigned int cell, IndexType value) |
| void | UpdateStatus () |
| bool | IndexIsEqualTo (const nmrMultiIndexCounter &other) const |
| void | GoToLowBounds () |
| void | GoToHighBounds () |
| void | GoTo (const IndexType where[]) |
| void | Increment () |
| void | Decrement () |
| CounterStatus | GetStatus () const |
| bool | IsAboveLowBounds () const |
| bool | IsBelowHighBounds () const |
| bool | IsBetweenBounds () const |
| unsigned long | GetNumberOfCombinations () const |
Static Public Attributes | |
| static const IndexType | DefaultIncrement |
Protected Types | |
| typedef std::vector< IndexType > | CounterType |
Protected Attributes | |
| CounterType | Index |
| CounterType | LowBounds |
| CounterType | HighBounds |
| CounterType | Increments |
| CounterStatus | Status |
|
protected |
| typedef int nmrMultiIndexCounter::IndexType |
| nmrMultiIndexCounter::nmrMultiIndexCounter | ( | unsigned int | size | ) |
| void nmrMultiIndexCounter::Decrement | ( | ) |
Decrement the counter by the values specified in SetIncements(). The last index changes fastest. When an index gets below the low bound, the previous index is decremented, and if there was an index that was decremented successfully, all the subsequent indices are wrapped back to their high bounds. When no index can be incremented, the status is set to COUNTER_UNDERFLOW.
Note that when the status is COUNTER_UNDERFLOW, the indices are not determined, as the loop semantics is using <= rather than <. In the current implementation, COUNTER_UNDERFLOW is reached with all indices below their low bounds. Yet this may change in future versions. One should not assume anything about a counter in COUNTER_OVERFLOW or COUNTER_UNDERFLOW status.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| unsigned long nmrMultiIndexCounter::GetNumberOfCombinations | ( | ) | const |
return the total number of possible states, or combinations, of the counter.
|
inline |
|
inline |
return one of UNDERLOW, COUNTER_IN_BOUNDS, COUNTER_OVERFLOW, COUNTER_UNDEFINED
|
inline |
|
inline |
|
inline |
Set the counter to the low bounds specified in SetBounds(). Set the status to COUNTER_IN_BOUNDS.
| void nmrMultiIndexCounter::Increment | ( | ) |
Increment the counter by the values specified in SetIncements(). The last index changes fastest. When an index passes the high bound, the previous index is incremented, and if there was an index that was incremented successfully, all the subsequent indices are wrapped back to their low bounds. When no index can be incremented, the status is set to COUNTER_OVERFLOW.
Note that when the status is COUNTER_OVERFLOW, the indices are not determined, as the loop semantics is using <= rather than <. In the current implementation, COUNTER_OVERFLOW is reached with all indices above their high bounds. Yet this may change in future versions. One should not assume anything about a counter in COUNTER_OVERFLOW or COUNTER_UNDERFLOW status.
| bool nmrMultiIndexCounter::IndexIsEqualTo | ( | const nmrMultiIndexCounter & | other | ) | const |
Compare the index cells of to multi-index counters. The method does not compare bounds, increments, etc.
|
inline |
return true if the status is defined and LowBounds <= Index
|
inline |
return true if the status is defined and Index <= HighBounds
|
inline |
Return true of the status is COUNTER_IN_BOUNDS
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |