das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
iterator.h
Go to the documentation of this file.
1/* Copyright (C) 2024 Chris Piker <chris-piker@uiowa.edu>
2 *
3 * This file is part of das2C, the Core Das2 C Library.
4 *
5 * Das2C is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 2.1 as published
7 * by the Free Software Foundation.
8 *
9 * Das2C is distributed in the hope that it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * version 2.1 along with das2C; if not, see <http://www.gnu.org/licenses/>.
16 */
17
20#ifndef _das_iterator_h_
21#define _das_iterator_h_
22
23#include <das3/dataset.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
67typedef struct dasds_iterator_t{
68
70 bool done;
71
74 ptrdiff_t index[VARIDX_MAX];
75
76 int rank;
77 ptrdiff_t shape[VARIDX_MAX]; /* Used for CUBIC datasets */
78 ptrdiff_t nLenIn; /* Used for ragged datasets */
79 bool ragged;
80 const DasDs* pDs;
81} DasDsIter;
82
99DAS_API void DasDsIter_init(DasDsIter* pThis, const DasDs* pDs);
100
117DAS_API bool DasDsIter_next(DasDsIter* pThis);
118
119/* ************************************************************************* */
120
123typedef struct das_uniq_iter_t{
125 bool done;
126
129 ptrdiff_t index[VARIDX_MAX];
130
132 bool lock[VARIDX_MAX];
133
135 int first;
136 int last;
137
138 int rank;
139 ptrdiff_t shape[VARIDX_MAX]; /* Used for CUBIC datasets */
140 ptrdiff_t nLenIn; /* Used for ragged datasets */
141 bool ragged;
142 const DasDs* pDs;
144
163 DasDsUniqIter* pThis, const DasDs* pDs, const DasVar* pVar
164);
165
183
184/* ************************************************************************* */
185
188typedef struct das_cube_iter_t{
189
191 bool done;
192
195 ptrdiff_t index[VARIDX_MAX];
196
197 int rank;
198 ptrdiff_t idxmin[VARIDX_MAX];
199 ptrdiff_t idxmax[VARIDX_MAX];
200
202
207 DasDsCubeIter* pThis, int nRank, ptrdiff_t* pMin, ptrdiff_t* pMax
208);
209
221
223typedef struct das_array_iter_t{
224 const DasAry* pAry;
225 bool done;
226 bool ragged; /* flag for no end_idx */
227 bool bNaturalEnd;
228 int rank;
229 ptrdiff_t index[VARIDX_MAX]; /* current index */
230 ptrdiff_t end_idx[VARIDX_MAX]; /* 1 after last valid index */
231 int dim_min;
232 int dim_max;
233
234 ptrdiff_t shape[VARIDX_MAX]; /* Used for CUBIC arrays */
235 ptrdiff_t nLenLast; /* Used for ragged arrays */
236} DasAryIter;
237
238
265DAS_API void DasAryIter_init(
266 DasAryIter* pThis, const DasAry* pAry, int iDimMin, int iDimMax, ptrdiff_t* pBeg,
267 ptrdiff_t* pEnd
268);
269
270
280DAS_API bool DasAryIter_next(DasAryIter* pThis);
281
282
283#ifdef __cplusplus
284}
285#endif
286
287#endif /* _das_dataset_h */
Objects which correlate arrays in index space.
#define VARIDX_MAX
Max index count for the model.
Definition generator.h:55
DAS_API bool DasAryIter_next(DasAryIter *pThis)
Increment an array iterated to the next expected index.
Iterate over a sub-set of the index space of a DasAry.
Definition iterator.h:223
DAS_API void DasAryIter_init(DasAryIter *pThis, const DasAry *pAry, int iDimMin, int iDimMax, ptrdiff_t *pBeg, ptrdiff_t *pEnd)
Initialize an array iterator.
Dynamic recursive ragged arrays.
Definition array.h:243
Simple cubic iterator.
Definition iterator.h:188
bool done
If true the value in index is valid, false otherwise.
Definition iterator.h:191
DAS_API void DasDsCubeIter_init(DasDsCubeIter *pThis, int nRank, ptrdiff_t *pMin, ptrdiff_t *pMax)
Initialize an iterator to cubic section in index space.
DAS_API bool DasDsCubeIter_next(DasDsCubeIter *pThis)
Increment a cubic iterator by one position, rolling as needed.
Dataset iterator structure.
Definition iterator.h:67
bool done
If true the value in index is valid, false otherwise.
Definition iterator.h:70
DAS_API bool DasDsIter_next(DasDsIter *pThis)
Increment the iterator's index by one position, rolling as needed at data boundaries.
DAS_API void DasDsIter_init(DasDsIter *pThis, const DasDs *pDs)
Initialize a const dataset iterator.
A non-degenerate iterator.
Definition iterator.h:123
bool done
If true the current value in the index is valid, false otherwise.
Definition iterator.h:125
DAS_API void DasDsUniqIter_init(DasDsUniqIter *pThis, const DasDs *pDs, const DasVar *pVar)
Initialize a non-degenerate iterator for a variable.
int first
Shortcut iteration by saving off the indexes that matter.
Definition iterator.h:135
DAS_API bool DasDsUniqIter_next(DasDsUniqIter *pThis)
Increment the iterator's index by one position, rolling as needed at data boundaries.
Das Datasets.
Definition dataset.h:159