cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Attributes | List of all members
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

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

Member Enumeration Documentation

Enumerator
COUNTER_UNDERFLOW 
COUNTER_IN_BOUNDS 
COUNTER_OVERFLOW 
COUNTER_UNDEFINED 

Constructor & Destructor Documentation

nmrMultiIndexCounter::nmrMultiIndexCounter ( unsigned int  size)

Member Function Documentation

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.

IndexType nmrMultiIndexCounter::GetHighBound ( unsigned int  counter) const
inline
const IndexType* nmrMultiIndexCounter::GetHighBounds ( ) const
inline
IndexType nmrMultiIndexCounter::GetIncrement ( unsigned int  counter) const
inline
const IndexType* nmrMultiIndexCounter::GetIncrements ( ) const
inline
const IndexType* nmrMultiIndexCounter::GetIndexCells ( ) const
inline
const unsigned int* nmrMultiIndexCounter::GetIndexCellsAsUnsigned ( ) const
inline
IndexType nmrMultiIndexCounter::GetLowBound ( unsigned int  counter) const
inline
const IndexType* nmrMultiIndexCounter::GetLowBounds ( ) const
inline
unsigned long nmrMultiIndexCounter::GetNumberOfCombinations ( ) const

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

unsigned int nmrMultiIndexCounter::GetSize ( void  ) const
inline
CounterStatus nmrMultiIndexCounter::GetStatus ( ) const
inline

return one of UNDERLOW, COUNTER_IN_BOUNDS, COUNTER_OVERFLOW, COUNTER_UNDEFINED

void nmrMultiIndexCounter::GoTo ( const IndexType  where[])
inline
void nmrMultiIndexCounter::GoToHighBounds ( )
inline
void nmrMultiIndexCounter::GoToLowBounds ( )
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.

bool nmrMultiIndexCounter::IsAboveLowBounds ( ) const
inline

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

bool nmrMultiIndexCounter::IsBelowHighBounds ( ) const
inline

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

bool nmrMultiIndexCounter::IsBetweenBounds ( ) const
inline

Return true of the status is COUNTER_IN_BOUNDS

IndexType nmrMultiIndexCounter::operator[] ( unsigned int  i) const
inline
void nmrMultiIndexCounter::SetAllIncrements ( IndexType  increment)
inline
void nmrMultiIndexCounter::SetBounds ( const IndexType  lowBounds[],
const IndexType  highBounds[] 
)
inline
void nmrMultiIndexCounter::SetHighBound ( unsigned int  counter,
IndexType  bound 
)
inline
void nmrMultiIndexCounter::SetIncrement ( unsigned int  counter,
IndexType  increment 
)
inline
void nmrMultiIndexCounter::SetIncrements ( const IndexType  increments[])
inline
void nmrMultiIndexCounter::SetIndex ( unsigned int  cell,
IndexType  value 
)
inline
void nmrMultiIndexCounter::SetLowBound ( unsigned int  counter,
IndexType  bound 
)
inline
void nmrMultiIndexCounter::UpdateStatus ( )
inline

Member Data Documentation

const IndexType nmrMultiIndexCounter::DefaultIncrement
static
CounterType nmrMultiIndexCounter::HighBounds
protected
CounterType nmrMultiIndexCounter::Increments
protected
CounterType nmrMultiIndexCounter::Index
protected
CounterType nmrMultiIndexCounter::LowBounds
protected
CounterStatus nmrMultiIndexCounter::Status
protected

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