Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType > Class Template Reference

Class to iterate through the GridContainer cells. More...

#include <GridContainer.h>

Inheritance diagram for Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >:
Inheritance graph
[legend]
Collaboration diagram for Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >:
Collaboration graph
[legend]

Public Member Functions

 iter (const GridContainer< GridCellManager, AxesTypes... > &owner, const cell_manager_iter_type &data_iter)
 Constructs a new iterator for the given grid.
 
 iter (const iter &)=default
 Copy constructor.
 
 iter (iter &&)=default
 Move constructor.
 
iteroperator= (const iter &other)
 Copy operator of the iterator.
 
iteroperator++ ()
 Moves the iterator to the next grid cell.
 
ReferenceType operator* ()
 Returns a reference to the cell value.
 
std::add_const< ReferenceType >::type operator* () const
 Returns a reference to the cell value (const version)
 
PointerType operator-> ()
 Returns a pointer to the cell value.
 
std::add_const< PointerType >::type operator-> () const
 Returns a pointer to the cell value (const version)
 
bool operator== (const iter &other) const
 
bool operator!= (const iter &other) const
 
template<int I>
size_t axisIndex () const
 
template<int I>
const axis_type< I > & axisValue () const
 
template<int I>
iterfixAxisByIndex (size_t index)
 
template<int I>
iterfixAxisByValue (const axis_type< I > &value)
 
template<typename OtherIter >
iterfixAllAxes (const OtherIter &other)
 

Private Member Functions

void forwardToIndex (size_t axis, size_t fixed_index)
 

Private Attributes

const GridContainer< GridCellManager, AxesTypes... > & m_owner
 
cell_manager_iter_type m_data_iter
 
std::map< size_t, size_t > m_fixed_indices
 

Detailed Description

template<typename GridCellManager, typename... AxesTypes>
template<typename CellType, typename PointerType, typename ReferenceType>
class Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >

Class to iterate through the GridContainer cells.

The GridContainer iterator provides efficient iteration through the cells of a GridContainer. If the axis information is not accessed, the iteration is almost as efficient as directly iterating through the GridCellManager. At any moment, the methods axisIndex() and axisValue() can be used to access the axes information. Slicing can be achieved by using the fixAxisByIndex() and fixAxisByValue() methods.

Definition at line 433 of file GridContainer.h.

Constructor & Destructor Documentation

◆ iter() [1/3]

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::iter ( const GridContainer< GridCellManager, AxesTypes... > &  owner,
const cell_manager_iter_type data_iter 
)

Constructs a new iterator for the given grid.

The cell on which the iterator points is controlled by the data_iter parameter, which is an iterator to the GridCellManager of the grid.

Parameters
ownerThe grid to iterate through
data_iterThe GridCellManager iterator indicating the cell position

◆ iter() [2/3]

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::iter ( const iter< CellType, PointerType, ReferenceType > &  )
default

Copy constructor.

◆ iter() [3/3]

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::iter ( iter< CellType, PointerType, ReferenceType > &&  )
default

Move constructor.

Member Function Documentation

◆ axisIndex()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
template<int I>
size_t Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::axisIndex ( ) const

Returns the index (coordinate) of the axis with index I, for the cell the iterator points

◆ axisValue()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
template<int I>
const axis_type< I > & Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::axisValue ( ) const

Returns the value of the axis with index I, for the cell the iterator points

◆ fixAllAxes()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
template<typename OtherIter >
iter & Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::fixAllAxes ( const OtherIter &  other)

Fixes all the axes of this iterator to the values of the axes of the given iterator. The given iterator is assumed to be an iterator of a grid with the same number of axes, with the same names. It is the responsibility of the caller to guarantee that.

Template Parameters
OtherIterThe type of the other iterator
Parameters
otherThe iterator to get the axes values from
Returns
the iterator with all its axes fixed

◆ fixAxisByIndex()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
template<int I>
iter & Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::fixAxisByIndex ( size_t  index)

Modifies the iterator to navigate only through cells with the given axis index. If the current cell does not fulfil this requirement the iterator will be forward to the first that does.

Template Parameters
Ithe index of the axis to fix
Parameters
indexthe index to fix the axis to
Returns
the iterator over the grid slice
Exceptions
Elements::Exceptionif the given index is out of the bounds of the axis
Elements::Exceptionif the axis has already been fixed for this iterator

◆ fixAxisByValue()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
template<int I>
iter & Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::fixAxisByValue ( const axis_type< I > &  value)

Modifies the iterator to navigate only through cells with the given axis value. If the current cell does not fulfill this requirement the iterator will be forward to the first that does.

Note that this method will search in the values of the axis, so it implies an overhead when compared with the fixAxisByIndex() method. For this reason the use of fixAxisByIndex() should be favored.

Template Parameters
Ithe index of the axis to fix
Parameters
valuethe value to fix the axis to
Returns
the iterator over the grid slice
Exceptions
Elements::Exceptionif the axis does not contain the given value
Elements::Exceptionif the axis has already been fixed for this iterator

◆ forwardToIndex()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
void Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::forwardToIndex ( size_t  axis,
size_t  fixed_index 
)
private

◆ operator!=()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
bool Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator!= ( const iter< CellType, PointerType, ReferenceType > &  other) const

Compares two iterators for inequality. Should be used only for iterators of the same grid.

◆ operator*() [1/2]

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
ReferenceType Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator* ( )

Returns a reference to the cell value.

◆ operator*() [2/2]

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
std::add_const< ReferenceType >::type Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator* ( ) const

Returns a reference to the cell value (const version)

◆ operator++()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
iter & Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator++ ( )

Moves the iterator to the next grid cell.

◆ operator->() [1/2]

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
PointerType Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator-> ( )

Returns a pointer to the cell value.

◆ operator->() [2/2]

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
std::add_const< PointerType >::type Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator-> ( ) const

Returns a pointer to the cell value (const version)

◆ operator=()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
iter & Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator= ( const iter< CellType, PointerType, ReferenceType > &  other)

Copy operator of the iterator.

◆ operator==()

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
bool Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::operator== ( const iter< CellType, PointerType, ReferenceType > &  other) const

Compares two iterators for equality. Should be used only for iterators of the same grid.

Member Data Documentation

◆ m_data_iter

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
cell_manager_iter_type Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::m_data_iter
private

Definition at line 539 of file GridContainer.h.

◆ m_fixed_indices

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
std::map<size_t, size_t> Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::m_fixed_indices
private

Definition at line 540 of file GridContainer.h.

◆ m_owner

template<typename GridCellManager , typename... AxesTypes>
template<typename CellType , typename PointerType , typename ReferenceType >
const GridContainer<GridCellManager, AxesTypes...>& Euclid::GridContainer::GridContainer< GridCellManager, AxesTypes >::iter< CellType, PointerType, ReferenceType >::m_owner
private

Definition at line 538 of file GridContainer.h.


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