13 template<std::
unsigned_
integral I, std::
unsigned_
integral S>
15 if (i < containerSize - 1) { i++; }
21 template<std::
unsigned_
integral I, std::
unsigned_
integral S>
24 else { i = containerSize - 1; }
29 template<std::
unsigned_
integral I, std::
unsigned_
integral S>
31 if (i < containerSize - 1) {
return i + 1; }
37 template<std::
unsigned_
integral I, std::
unsigned_
integral S>
39 if (i > 0) {
return i - 1; }
40 else {
return containerSize - 1; }
50 template<std::
integral I, std::
unsigned_
integral S>
53 return (containerSize - 1) - (-i) % containerSize;
55 else if (i >=
static_cast<int>(containerSize)) {
56 return i % containerSize;
void incrementIndex(I &i, const S containerSize)
Increment an index. Up to containerSize, then restart at 0.
Definition: util.hpp:14
void decrementIndex(I &i, const S containerSize)
Decrement an index. Down to 0, then restart at containerSize - 1.
Definition: util.hpp:22
I getDecrementedIndex(const I i, const S containerSize)
Like decrementIndex, but returns a new number.
Definition: util.hpp:38
std::size_t getValidIndex(const I i, const S containerSize)
Wrap an index around, to make it valid.
Definition: util.hpp:51
I getIncrementedIndex(const I i, const S containerSize)
Like incrementIndex, but returns a new number.
Definition: util.hpp:30