SpECTRE  v2024.04.12
IndexIterator< Dim > Class Template Reference

IndexIterator iterates over a unique set of Index. More...

#include <IndexIterator.hpp>

Public Member Functions

 IndexIterator (Index< Dim > extents)
 Construct from an Index.
 
 IndexIterator ()=delete
 It does not make sense to default construct an IndexIterator.
 
 operator bool () const
 Returns false if the end of the Index iteration is reached.
 
IndexIterator< Dim > & operator++ ()
 Advance to next Index.
 
const Index< Dim > & operator* () const
 
const Index< Dim > * operator-> () const
 
const Index< Dim > & operator() () const
 Returns an index representing the (i, j, ...)th values that the iterator currently represents.
 
size_t collapsed_index () const
 Get the collapsed index into a 1D array of the data corresponding to the current Index of the IndexIterator. Note that the first dimension of the Index varies fastest when computing the collapsed index.
 

Detailed Description

template<std::size_t Dim>
class IndexIterator< Dim >

IndexIterator iterates over a unique set of Index.

Example

Index<3> elements(1, 2, 3);
for (IndexIterator<3> index_it(elements); index_it; ++index_it) {
// Use the index iterator to do something super awesome
CHECK(Index<3>(-1, -1, -1) != *index_it);
}
IndexIterator iterates over a unique set of Index.
Definition: IndexIterator.hpp:22
An integer multi-index.
Definition: Index.hpp:31

Each integer of the Index will vary from 0 to extents[d] - 1, with the lowest dimension varying the fastest.


The documentation for this class was generated from the following file: