Backward chunk iteration on UDO's



If I understand right, a ConstChunkIterator can only advance forward. The operator–() is not implemented.
Is there a way I can iterate backwards if I set the position of the iterator at getChunk().getLastPosition(); ??



Hi Mike,

With most arrays, you can usually pick one attribute, iterate forward over it, record a list of all the chunk positions (without opening the chunks). Then you can use that list to call setPosition() on the array in whatever order you want. There is a small number of arrays that doesn’t support this - for example the InputArray could be reading data from a filesystem pipe, so you may only iterate over it once. To find out if rewind is supported, check Array::getSupportedAccess(). If that doesn’t return RANDOM, you need to copy your array to a MemArray (or just throw an error asking the user to store the array manually).

There are also methods:
But they haven’t been threaded all the way through the API. You can call or emulate findChunkPositions in your code.
See the doxygen comments in include/array/Array.h

Finally, remember that given a chunk position {x,y}, all attributes for that chunk will always be on the same instance.