6#include <QtCore/QVector>
57 template <
int Dimensions>
62 return std::vector<int>(m_elements.begin(), m_elements.end());
116 int GetAt(
int index)
const;
121 void SetAt(
int index,
int value);
234 return int(m_elements.size());
240 int lastSize = m_elements.size();
242 m_elements.resize(count);
244 for (
int i = lastSize; i < count; ++i){
245 m_elements[i] = value;
254 Q_ASSERT(index >= 0);
255 Q_ASSERT(index <
int(m_elements.size()));
257 return m_elements[index];
263 Q_ASSERT(index >= 0);
264 Q_ASSERT(index <
int(m_elements.size()));
266 m_elements[index] = value;
272 Q_ASSERT(index >= 0);
273 Q_ASSERT(index <
int(m_elements.size()));
283 Q_ASSERT(index >= 0);
284 Q_ASSERT(index <
int(m_elements.size()));
298 for (
int i = 0; i < dimensionsCount; ++i){
310 for (
int i = dimensionsCount - 1; i >= 0; --i){
324 retVal.m_elements += other.m_elements;
332 return const_cast<CVarIndex*
>(
this)->m_elements.begin();
338 return const_cast<CVarIndex*
>(
this)->m_elements.end();
350 Q_ASSERT(index >= 0);
351 Q_ASSERT(index <
int(m_elements.size()));
353 return m_elements[index];
360 int count = m_elements.size();
361 int indexCount = index.m_elements.size();
362 int commonSize = qMin(count, indexCount);
363 for (
int i = 0; i < commonSize; ++i){
364 int element = m_elements[i];
365 int indexElement = index.m_elements[i];
366 if (element != indexElement){
367 return element < indexElement;
371 return count < indexCount;
377 int count = m_elements.size();
378 int indexCount = index.m_elements.size();
379 int commonSize = qMin(count, indexCount);
380 for (
int i = 0; i < commonSize; ++i){
381 int element = m_elements[i];
382 int indexElement = index.m_elements[i];
383 if (element != indexElement){
384 return element > indexElement;
388 return count > indexCount;
394 int count = m_elements.size();
395 int indexCount = index.m_elements.size();
396 int commonSize = qMin(count, indexCount);
397 for (
int i = 0; i < commonSize; ++i){
398 int element = m_elements[i];
399 int indexElement = index.m_elements[i];
400 if (element != indexElement){
401 return element < indexElement;
405 return count <= indexCount;
411 int count = m_elements.size();
412 int indexCount = index.m_elements.size();
413 int commonSize = qMin(count, indexCount);
414 for (
int i = 0; i < commonSize; ++i){
415 int element = m_elements[i];
416 int indexElement = index.m_elements[i];
417 if (element != indexElement){
418 return element > indexElement;
422 return count >= indexCount;
428template <
int Dimensions>
430: m_elements(Dimensions)
432 for (
int i = 0; i < Dimensions; ++i){
433 m_elements[i] = index[i];
Multidimensional index used to addressing index.
CVarIndex(const std::vector< IndexType > &values)
Construct index from std::vector.
void Clear()
Set all components to 0.
bool IsValid() const
Check if tihs index is valid.
bool operator>(const CVarIndex &index) const
friend uint qHash(const CVarIndex &index, uint seed)
CVarIndex(int size, int value=0)
Constructor initializing all member to specified value.
CVarIndex(const Elements &values)
Construct index from QVector.
bool operator<=(const CVarIndex &index) const
bool operator!=(const CVarIndex &index) const
bool IsDimensionsCountFixed() const
Check, if number dimensions is fixed.
bool IncreaseAt(int index)
Increase single component at specified position.
std::vector< int > ToStdVector() const
int GetMinDimensionsCount() const
Get minimal number of dimensions needed to to represent this index.
bool Increase(const CVarIndex &boundaries)
Increase this index inside the boundaries.
CVarIndex & operator+=(const CVarIndex &index)
bool IsSizeEmpty() const
Check if this index interpreted as size is empty.
Elements::iterator Iterator
int GetAt(int index) const
Get element stored at specified index.
bool IsZero() const
Check if this index point at zero element.
CVarIndex & operator=(const CVarIndex &index)
void SetAt(int index, int value)
Set element at specified index.
CVarIndex(const CVarIndex &index)
Copy constructor.
void SetAllTo(int value)
Set all components to specified value.
int GetProductVolume() const
Get total number of elements if this index is treated as size.
bool operator<(const CVarIndex &index) const
void Reset()
Reset this object.
bool IsInside(const CVarIndex &boundaries) const
Check if index is inside boundaries.
int operator[](int index) const
Get access to single index components.
bool operator>=(const CVarIndex &index) const
int GetDimensionsCount() const
Get number of dimensions of this index.
bool operator==(const CVarIndex &index) const
istd::CVarIndex GetExpanded(const istd::CVarIndex &other) const
Get the index expanded by another index.
bool SetDimensionsCount(int count, int value=0)
Set number of dimensions of this index.
bool DecreaseAt(int index)
Decrease single component at specified position.
int GetIterationIndex(const CVarIndex &boundaries) const
Get index of iteration from zero to current index inside some boundaries.
Iterator Begin() const
Get begin value of element access iterator.
bool Decrease(const CVarIndex &boundaries)
Decrese this index inside the boundaries.
CVarIndex & operator-=(const CVarIndex &index)
Iterator End() const
Get end value of element access iterator.
CVarIndex()
Default constructor without member initialization.
Multidimensional index used to addressing fixed-size array.
uint qHash(const CVarIndex &index, uint seed=0)