Public Types | Public Member Functions | Friends | List of all members
istd::CVarIndex Class Reference

Multidimensional index used to addressing index. More...

#include <CVarIndex.h>

Inheritance diagram for istd::CVarIndex:
istd::TVarArray< Element >::Iterator

Public Types

typedef int IndexType
 
typedef QVector< int >::iterator Iterator
 

Public Member Functions

 CVarIndex ()
 Default constructor without member initialization. More...
 
 CVarIndex (int size, int value=0)
 Constructor initializing all member to specified value. More...
 
 CVarIndex (const CVarIndex &index)
 Copy constructor. More...
 
template<int Dimensions>
 CVarIndex (const TIndex< Dimensions > index)
 Convert fixed-size index to this object. More...
 
bool IsValid () const
 Check if tihs index is valid. More...
 
bool IsZero () const
 Check if this index point at zero element. More...
 
bool IsSizeEmpty () const
 Check if this index interpreted as size is empty. More...
 
void Reset ()
 Reset this object. More...
 
void Clear ()
 Set all components to 0. More...
 
bool IsDimensionsCountFixed () const
 Check, if number dimensions is fixed. More...
 
int GetDimensionsCount () const
 Get number of dimensions of this index. More...
 
bool SetDimensionsCount (int count, int value=0)
 Set number of dimensions of this index. More...
 
int GetAt (int index) const
 Get element stored at specified index. More...
 
void SetAt (int index, int value)
 Set element at specified index. More...
 
void SetAllTo (int value)
 Set all components to specified value. More...
 
bool IncreaseAt (int index)
 Increase single component at specified position. More...
 
bool DecreaseAt (int index)
 Decrease single component at specified position. More...
 
bool IsInside (const CVarIndex &boundaries) const
 Check if index is inside boundaries. More...
 
bool Increase (const CVarIndex &boundaries)
 Increase this index inside the boundaries. More...
 
bool Decrease (const CVarIndex &boundaries)
 Decrese this index inside the boundaries. More...
 
int GetProductVolume () const
 Get total number of elements if this index is treated as size. More...
 
int GetIterationIndex (const CVarIndex &boundaries) const
 Get index of iteration from zero to current index inside some boundaries. More...
 
int GetMinDimensionsCount () const
 Get minimal number of dimensions needed to to represent this index. More...
 
Iterator Begin () const
 Get begin value of element access iterator. More...
 
Iterator End () const
 Get end value of element access iterator. More...
 
int operator[] (int index) const
 Get access to single index components. More...
 
int & operator[] (int index)
 Get access to single index components. More...
 
bool operator== (const CVarIndex &index) const
 
bool operator!= (const CVarIndex &index) const
 
bool operator< (const CVarIndex &index) const
 
bool operator> (const CVarIndex &index) const
 
bool operator<= (const CVarIndex &index) const
 
bool operator>= (const CVarIndex &index) const
 
CVarIndexoperator= (const CVarIndex &index)
 
CVarIndexoperator+= (const CVarIndex &index)
 
CVarIndexoperator-= (const CVarIndex &index)
 

Friends

uint qHash (const CVarIndex &index, uint seed)
 

Detailed Description

Multidimensional index used to addressing index.

Definition at line 19 of file CVarIndex.h.

Member Typedef Documentation

Definition at line 22 of file CVarIndex.h.

typedef QVector<int>::iterator istd::CVarIndex::Iterator

Definition at line 23 of file CVarIndex.h.

Constructor & Destructor Documentation

istd::CVarIndex::CVarIndex ( )

Default constructor without member initialization.

istd::CVarIndex::CVarIndex ( int  size,
int  value = 0 
)
explicit

Constructor initializing all member to specified value.

istd::CVarIndex::CVarIndex ( const CVarIndex index)

Copy constructor.

template<int Dimensions>
istd::CVarIndex::CVarIndex ( const TIndex< Dimensions >  index)

Convert fixed-size index to this object.

Definition at line 395 of file CVarIndex.h.

Member Function Documentation

CVarIndex::Iterator istd::CVarIndex::Begin ( ) const
inline

Get begin value of element access iterator.

Please refer to general description of ACF iterators, STL iterators or Qt iterators concept.

Definition at line 296 of file CVarIndex.h.

void istd::CVarIndex::Clear ( )

Set all components to 0.

bool istd::CVarIndex::Decrease ( const CVarIndex boundaries)

Decrese this index inside the boundaries.

Please note, that the number of dimensions for this index will not be changed and this operation can be unclear when number of dimensions differs from boundaries number of dimensions.

Returns
false, if decrease wasn't possible (e.g. overflow).
bool istd::CVarIndex::DecreaseAt ( int  index)
inline

Decrease single component at specified position.

Parameters
indexindex of component should be increased. It must be valid.
Returns
true if success. It is provided for template implementations. In this case it returns always true.

Definition at line 257 of file CVarIndex.h.

CVarIndex::Iterator istd::CVarIndex::End ( ) const
inline

Get end value of element access iterator.

Please refer to general description of ACF iterators, STL iterators or Qt iterators concept.

Definition at line 302 of file CVarIndex.h.

int istd::CVarIndex::GetAt ( int  index) const
inline

Get element stored at specified index.

Definition at line 228 of file CVarIndex.h.

Referenced by GetMinDimensionsCount(), GetProductVolume(), and operator[]().

int istd::CVarIndex::GetDimensionsCount ( ) const
inline

Get number of dimensions of this index.

Definition at line 208 of file CVarIndex.h.

Referenced by istd::TVarArray< Element >::GetElementIndex(), GetMinDimensionsCount(), and GetProductVolume().

int istd::CVarIndex::GetIterationIndex ( const CVarIndex boundaries) const

Get index of iteration from zero to current index inside some boundaries.

int istd::CVarIndex::GetMinDimensionsCount ( ) const
inline

Get minimal number of dimensions needed to to represent this index.

In other words this is index of last non-zero component + 1.

Definition at line 282 of file CVarIndex.h.

References GetAt(), and GetDimensionsCount().

int istd::CVarIndex::GetProductVolume ( ) const
inline

Get total number of elements if this index is treated as size.

Returns
multiplication of all elements.

Definition at line 268 of file CVarIndex.h.

References GetAt(), and GetDimensionsCount().

bool istd::CVarIndex::Increase ( const CVarIndex boundaries)

Increase this index inside the boundaries.

Please note, that the number of dimensions for this index will not be changed and this operation can be unclear when number of dimensions differs from boundaries number of dimensions.

Returns
false, if increase wasn't possible (e.g. overflow).
bool istd::CVarIndex::IncreaseAt ( int  index)
inline

Increase single component at specified position.

Parameters
indexindex of component should be increased. It must be valid.
Returns
true if success. It is provided for template implementations. In this case it returns always true.

Definition at line 246 of file CVarIndex.h.

bool istd::CVarIndex::IsDimensionsCountFixed ( ) const
inline

Check, if number dimensions is fixed.

It is provided for template implementations. It returns always false.

Definition at line 202 of file CVarIndex.h.

bool istd::CVarIndex::IsInside ( const CVarIndex boundaries) const

Check if index is inside boundaries.

Index is inside boundaries, if all its components are smaller than according boundary components.

Referenced by istd::TVarArray< Element >::GetAt(), and istd::TVarArray< Element >::SetAt().

bool istd::CVarIndex::IsSizeEmpty ( ) const

Check if this index interpreted as size is empty.

It means, it returns true, is some of components is less or equal 0.

bool istd::CVarIndex::IsValid ( ) const

Check if tihs index is valid.

Index is valid if it has elements and all elements are not negative.

bool istd::CVarIndex::IsZero ( ) const

Check if this index point at zero element.

In other words, it checks if all components are 0.

bool istd::CVarIndex::operator!= ( const CVarIndex index) const
CVarIndex& istd::CVarIndex::operator+= ( const CVarIndex index)
CVarIndex& istd::CVarIndex::operator-= ( const CVarIndex index)
bool istd::CVarIndex::operator< ( const CVarIndex index) const
inline

Definition at line 324 of file CVarIndex.h.

bool istd::CVarIndex::operator<= ( const CVarIndex index) const
inline

Definition at line 358 of file CVarIndex.h.

CVarIndex& istd::CVarIndex::operator= ( const CVarIndex index)
bool istd::CVarIndex::operator== ( const CVarIndex index) const
bool istd::CVarIndex::operator> ( const CVarIndex index) const
inline

Definition at line 341 of file CVarIndex.h.

bool istd::CVarIndex::operator>= ( const CVarIndex index) const
inline

Definition at line 375 of file CVarIndex.h.

int istd::CVarIndex::operator[] ( int  index) const
inline

Get access to single index components.

Definition at line 308 of file CVarIndex.h.

References GetAt().

int & istd::CVarIndex::operator[] ( int  index)
inline

Get access to single index components.

Definition at line 314 of file CVarIndex.h.

void istd::CVarIndex::Reset ( )

Reset this object.

For this (variable size) implementation, it set dimension size to 0.

void istd::CVarIndex::SetAllTo ( int  value)

Set all components to specified value.

void istd::CVarIndex::SetAt ( int  index,
int  value 
)
inline

Set element at specified index.

Definition at line 237 of file CVarIndex.h.

bool istd::CVarIndex::SetDimensionsCount ( int  count,
int  value = 0 
)
inline

Set number of dimensions of this index.

It is provided to allows template implementations to use fixed-size or variable arrays.

Parameters
countnumber of dimensions will be set.
Returns
always true.

Definition at line 214 of file CVarIndex.h.

Friends And Related Function Documentation

uint qHash ( const CVarIndex index,
uint  seed 
)
friend

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

© 2007-2017 Witold Gantzke and Kirill Lepskiy