The SKIRT project
advanced radiative transfer for astrophysics
Classes | Public Member Functions | Private Attributes | List of all members
Indices Class Reference

#include <Indices.hpp>

Classes

class  Iterator
 

Public Member Functions

template<class C >
 Indices (C cont, bool reverse=false)
 
 Indices (int range, bool reverse=false)
 
Iterator begin () const
 
Iterator end () const
 

Private Attributes

int _range
 
bool _reverse
 

Detailed Description

The Indices class can be used to iterate over zero-based indices of type int in forward or backward order based on a run-time flag. For example:

for (int index : Indices(4)) { } // loops over 0,1,2,3
for (int index : Indices(4, true)) { } // loops over 3,2,1,0
Definition: Indices.hpp:31

It is also possible to specify any container that implements size():

vector xv(4);
for (int index : Indices(xv)) { } // loops over 0,1,2,3
for (int index : Indices(xv, true)) { } // loops over 3,2,1,0

Constructor & Destructor Documentation

◆ Indices() [1/2]

Indices::Indices ( int  range,
bool  reverse = false 
)
inline

This constructor intializes an index range with the specified number of zero-based indices. The second argument indicates iteration direction: false (or missing) for forward iteration; true for backward iteration.

◆ Indices() [2/2]

template<class C >
Indices::Indices ( cont,
bool  reverse = false 
)
inline

This constructor intializes an index range with a number of zero-based indices corresponding to the size of the specified container. The container class must implement the size() function. The second argument indicates iteration direction: false (or missing) for forward iteration; true for backward iteration.

Member Function Documentation

◆ begin()

Iterator Indices::begin ( ) const
inline

This function returns the begin iterator corresponding to the iteration direction.

◆ end()

Iterator Indices::end ( ) const
inline

This function returns the end iterator corresponding to the iteration direction.


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