![]() |
das2C
das core C utilities (v3)
|
Dataset iterator structure. More...
#include <das2/dataset.h>
Public Member Functions | |
DAS_API void | dasds_iter_init (dasds_iterator *pIter, const DasDs *pDs) |
Initialize a const dataset iterator. More... | |
DAS_API bool | dasds_iter_next (dasds_iterator *pIter) |
Increment the iterator's index by one position, rolling as needed at data boundaries. More... | |
Data Fields | |
bool | done |
If true the value in index is valid, false otherwise. | |
ptrdiff_t | index [DASIDX_MAX] |
A dataset bulk iteration index suitable for use in DasVar functions like ::DasVar_getDatum. | |
Dataset iterator structure.
Since dataset rank and shape is a union of the shape of it's components iterating over datasets can be tricky. This structure and it's associated functions are provided to simplify this task. Usage is demonstrated by the example below:
DAS_API void dasds_iter_init | ( | dasds_iterator * | pIter, |
const DasDs * | pDs | ||
) |
Initialize a const dataset iterator.
The initialized iterator is safe to use for datasets that are growing as it will not exceed the valid index range of the dataset at the time this function was called. However, if the dataset shrinks during iteration das_iter_next() could overstep the array bounds.
For usage see the example in ::das_iterator
pIter | A pointer to an iterator, will be initialize to index 0 |
pDs | A pointer to a dataset. If the dataset changes while the iterator is in use invalid memory access could occur |
DAS_API bool dasds_iter_next | ( | dasds_iterator * | pIter | ) |
Increment the iterator's index by one position, rolling as needed at data boundaries.
For efficiency this function does not re-check array bounds on each call a slower but safer version of this function could be created if needed.
For usage see the example in ::das_iterator
pIter | A pointer to an iterator. The index member of the iterator will be incremented. |