bes
Updated for version 3.20.6
|
#include <Odometer.h>
Public Types | |
typedef std::vector< unsigned int > | shape |
Public Member Functions | |
unsigned int | end () |
void | indices (shape &indices) |
unsigned int | next () |
unsigned int | next_safe () |
Odometer (shape shape) | |
unsigned int | offset () |
void | reset () |
unsigned int | set_indices (const shape &indices) |
unsigned int | set_indices (const std::vector< int > &indices) |
Map the indices of a N-dimensional array to the offset into memory (i.e., a vector) that matches those indices. This code can be used to step through each element of an N-dim array without using multiplication to compute the offset into the vector that holds the array's data.
Definition at line 43 of file Odometer.h.
|
inline |
Build an instance of Odometer using the given 'shape'. Each element of the shape vector is the size of the corresponding dimension. E.G., a 10 by 20 by 30 array would be described by a vector of 10,20,30.
Initially, the Odometer object is set to index 0, 0, ..., 0 that matches the offset 0
Definition at line 67 of file Odometer.h.
|
inline |
Return the sentinel value that indicates that the offset (returned by offset()) is at the end of the array. When offset() < end() the values of offset() and indices() are valid elements of the array being indexed. When offset() == end(), the values are no longer valid and the last array element has been visited.
Definition at line 218 of file Odometer.h.
|
inline |
Return the current set of indices. These match the current offset. Both the offset and indices are incremented by the next() method.
To access the ith index, use [i] or .at(i)
Definition at line 198 of file Odometer.h.
|
inline |
Increment the Odometer to the next element and return the offset value. This increments the internal state and returns the offset to that element in a vector of values. Calling indices() after calling this method will return a vector<unsigned int> of the current index value.
Definition at line 129 of file Odometer.h.
|
inline |
The offset into memory for the current element.
Definition at line 206 of file Odometer.h.
|
inline |
Reset the internal state. The offset is reset to the 0th element and the indices are reset to 0, 0, ..., 0.
Definition at line 111 of file Odometer.h.
|
inline |
Given a set of indices, update offset to match the position in the memory/vector they correspond to given the Odometer's initial shape.
indices | Indices of an element |
Definition at line 155 of file Odometer.h.