cisst-saw
Loading...
Searching...
No Matches
nmrMultiIndexCounter Class Reference

#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 IndexTypeGetIndexCells () const
const unsigned int * GetIndexCellsAsUnsigned () const
const IndexTypeGetLowBounds () const
IndexType GetLowBound (unsigned int counter) const
const IndexTypeGetHighBounds () const
IndexType GetHighBound (unsigned int counter) const
const IndexTypeGetIncrements () 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< IndexTypeCounterType

Protected Attributes

CounterType Index
CounterType LowBounds
CounterType HighBounds
CounterType Increments
CounterStatus Status

Member Typedef Documentation

◆ CounterType

typedef std::vector<IndexType> nmrMultiIndexCounter::CounterType
protected

◆ IndexType

Member Enumeration Documentation

◆ CounterStatus

Enumerator
COUNTER_UNDERFLOW 
COUNTER_IN_BOUNDS 
COUNTER_OVERFLOW 
COUNTER_UNDEFINED 

Constructor & Destructor Documentation

◆ nmrMultiIndexCounter()

nmrMultiIndexCounter::nmrMultiIndexCounter ( unsigned int size)

Member Function Documentation

◆ Decrement()

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.

◆ GetHighBound()

IndexType nmrMultiIndexCounter::GetHighBound ( unsigned int counter) const
inline

◆ GetHighBounds()

const IndexType * nmrMultiIndexCounter::GetHighBounds ( ) const
inline

◆ GetIncrement()

IndexType nmrMultiIndexCounter::GetIncrement ( unsigned int counter) const
inline

◆ GetIncrements()

const IndexType * nmrMultiIndexCounter::GetIncrements ( ) const
inline

◆ GetIndexCells()

const IndexType * nmrMultiIndexCounter::GetIndexCells ( ) const
inline

◆ GetIndexCellsAsUnsigned()

const unsigned int * nmrMultiIndexCounter::GetIndexCellsAsUnsigned ( ) const
inline

◆ GetLowBound()

IndexType nmrMultiIndexCounter::GetLowBound ( unsigned int counter) const
inline

◆ GetLowBounds()

const IndexType * nmrMultiIndexCounter::GetLowBounds ( ) const
inline

◆ GetNumberOfCombinations()

unsigned long nmrMultiIndexCounter::GetNumberOfCombinations ( ) const

return the total number of possible states, or combinations, of the counter.

◆ GetSize()

unsigned int nmrMultiIndexCounter::GetSize ( ) const
inline

◆ GetStatus()

CounterStatus nmrMultiIndexCounter::GetStatus ( ) const
inline

return one of UNDERLOW, COUNTER_IN_BOUNDS, COUNTER_OVERFLOW, COUNTER_UNDEFINED

◆ GoTo()

void nmrMultiIndexCounter::GoTo ( const IndexType where[])
inline

◆ GoToHighBounds()

void nmrMultiIndexCounter::GoToHighBounds ( )
inline

◆ GoToLowBounds()

void nmrMultiIndexCounter::GoToLowBounds ( )
inline

Set the counter to the low bounds specified in SetBounds(). Set the status to COUNTER_IN_BOUNDS.

◆ Increment()

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.

◆ IndexIsEqualTo()

bool nmrMultiIndexCounter::IndexIsEqualTo ( const nmrMultiIndexCounter & other) const

Compare the index cells of to multi-index counters. The method does not compare bounds, increments, etc.

◆ IsAboveLowBounds()

bool nmrMultiIndexCounter::IsAboveLowBounds ( ) const
inline

return true if the status is defined and LowBounds <= Index

◆ IsBelowHighBounds()

bool nmrMultiIndexCounter::IsBelowHighBounds ( ) const
inline

return true if the status is defined and Index <= HighBounds

◆ IsBetweenBounds()

bool nmrMultiIndexCounter::IsBetweenBounds ( ) const
inline

Return true of the status is COUNTER_IN_BOUNDS

◆ operator[]()

IndexType nmrMultiIndexCounter::operator[] ( unsigned int i) const
inline

◆ SetAllIncrements()

void nmrMultiIndexCounter::SetAllIncrements ( IndexType increment)
inline

◆ SetBounds()

void nmrMultiIndexCounter::SetBounds ( const IndexType lowBounds[],
const IndexType highBounds[] )
inline

◆ SetHighBound()

void nmrMultiIndexCounter::SetHighBound ( unsigned int counter,
IndexType bound )
inline

◆ SetIncrement()

void nmrMultiIndexCounter::SetIncrement ( unsigned int counter,
IndexType increment )
inline

◆ SetIncrements()

void nmrMultiIndexCounter::SetIncrements ( const IndexType increments[])
inline

◆ SetIndex()

void nmrMultiIndexCounter::SetIndex ( unsigned int cell,
IndexType value )
inline

◆ SetLowBound()

void nmrMultiIndexCounter::SetLowBound ( unsigned int counter,
IndexType bound )
inline

◆ UpdateStatus()

void nmrMultiIndexCounter::UpdateStatus ( )
inline

Member Data Documentation

◆ DefaultIncrement

const IndexType nmrMultiIndexCounter::DefaultIncrement
static

◆ HighBounds

CounterType nmrMultiIndexCounter::HighBounds
protected

◆ Increments

CounterType nmrMultiIndexCounter::Increments
protected

◆ Index

CounterType nmrMultiIndexCounter::Index
protected

◆ LowBounds

CounterType nmrMultiIndexCounter::LowBounds
protected

◆ Status

CounterStatus nmrMultiIndexCounter::Status
protected

The documentation for this class was generated from the following file: