|
OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
Map the indices of a N-dimensional array to the offset into memory that matches those indices. More...
#include <Odometer.h>

Public Types | |
| typedef std::vector< unsigned int > | shape |
Public Member Functions | |
| unsigned int | end () |
| Return the sentinel value that indicates that the offset (returned by offset()) is at the end of the array. More... | |
| void | indices (shape &indices) |
| Return the current set of indices. More... | |
| unsigned int | next () |
| Increment the Odometer to the next element and return the offset value. More... | |
| unsigned int | next_safe () |
| Odometer (shape shape) | |
| Build an instance of Odometer using the given 'shape'. More... | |
| unsigned int | offset () |
| The offset into memory for the current element. More... | |
| void | reset () |
| Reset the internal state. More... | |
Map the indices of a N-dimensional array to the offset into memory 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 38 of file Odometer.h.
| typedef std::vector<unsigned int> libdap::Odometer::shape |
Definition at line 41 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 62 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 154 of file Odometer.h.
Referenced by libdap::function_dap2_bbox().
|
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 134 of file Odometer.h.
Referenced by libdap::function_dap2_bbox().
|
inline |
Increment the Odometer to the next element and return the offset value.
This increments the internal state so that calling indices() 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 107 of file Odometer.h.
Referenced by libdap::function_dap2_bbox().
| unsigned int libdap::Odometer::next_safe | ( | ) |
Definition at line 38 of file Odometer.cc.
|
inline |
The offset into memory for the current element.
Definition at line 142 of file Odometer.h.
Referenced by libdap::function_dap2_bbox().
|
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 89 of file Odometer.h.