OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::MultiIndex< D >::Iterator Class Reference

Iterator class for iterating over multi-dimensional indices. More...

#include <multi_index.hpp>

Public Member Functions

 Iterator (std::array< int, D > indices, const MultiIndex &multi_index)
 Constructs an Iterator object with the specified indices and MultiIndex object.
 
 Iterator (int linear_index, const MultiIndex &multi_index)
 Constructs an Iterator object with the specified linear index and MultiIndex object.
 
std::array< int, D > & operator* ()
 Dereferences the iterator to obtain the current multi-dimensional indices.
 
Iteratoroperator++ ()
 Advances the iterator to the next position.
 
Iterator operator++ (int)
 Advances the iterator to the next position (post-increment).
 
Iterator operator- (int n) const
 Subtraction operator for the Iterator class.
 
bool operator!= (const Iterator &other) const
 Compares two iterators for inequality.
 
bool operator== (const Iterator &other) const
 Compares two iterators for equality.
 
 operator size_t () const
 Conversion operator to obtain the current linear index.
 
 operator std::array< int, D > () const
 Conversion operator to obtain the current multi-dimensional indices.
 
size_t get_linear_index () const
 Returns the current linear index.
 

Friends

std::ostream & operator<< (std::ostream &os, const Iterator &it)
 Outputs the current multi-dimensional indices to the specified output stream.
 

Detailed Description

template<size_t D>
class pfc::MultiIndex< D >::Iterator

Iterator class for iterating over multi-dimensional indices.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

template<size_t D>
pfc::MultiIndex< D >::Iterator::Iterator ( std::array< int, D >  indices,
const MultiIndex multi_index 
)
inline

Constructs an Iterator object with the specified indices and MultiIndex object.

Parameters
indicesThe initial multi-dimensional indices.
multi_indexReference to the MultiIndex object.
Here is the call graph for this function:

◆ Iterator() [2/2]

template<size_t D>
pfc::MultiIndex< D >::Iterator::Iterator ( int  linear_index,
const MultiIndex multi_index 
)
inline

Constructs an Iterator object with the specified linear index and MultiIndex object.

Parameters
linear_indexThe initial linear index.
multi_indexReference to the MultiIndex object.
Here is the call graph for this function:

Member Function Documentation

◆ get_linear_index()

template<size_t D>
size_t pfc::MultiIndex< D >::Iterator::get_linear_index ( ) const
inline

Returns the current linear index.

Returns
The current linear index.

◆ operator size_t()

template<size_t D>
pfc::MultiIndex< D >::Iterator::operator size_t ( ) const
inline

Conversion operator to obtain the current linear index.

Returns
The current linear index.

◆ operator std::array< int, D >()

template<size_t D>
pfc::MultiIndex< D >::Iterator::operator std::array< int, D > ( ) const
inline

Conversion operator to obtain the current multi-dimensional indices.

Returns
The current multi-dimensional indices.

◆ operator!=()

template<size_t D>
bool pfc::MultiIndex< D >::Iterator::operator!= ( const Iterator other) const
inline

Compares two iterators for inequality.

Parameters
otherThe iterator to compare.
Returns
True if the iterators are not equal, false otherwise.

◆ operator*()

template<size_t D>
std::array< int, D > & pfc::MultiIndex< D >::Iterator::operator* ( )
inline

Dereferences the iterator to obtain the current multi-dimensional indices.

Returns
A reference to the current multi-dimensional indices.

◆ operator++() [1/2]

template<size_t D>
Iterator & pfc::MultiIndex< D >::Iterator::operator++ ( )
inline

Advances the iterator to the next position.

Returns
Reference to the updated iterator.

◆ operator++() [2/2]

template<size_t D>
Iterator pfc::MultiIndex< D >::Iterator::operator++ ( int  )
inline

Advances the iterator to the next position (post-increment).

Returns
A copy of the iterator before the increment.

◆ operator-()

template<size_t D>
Iterator pfc::MultiIndex< D >::Iterator::operator- ( int  n) const
inline

Subtraction operator for the Iterator class.

This operator subtracts the specified number of positions from the current iterator position. It returns a new iterator pointing to the element at the updated position.

Parameters
nThe number of positions to subtract from the current iterator position.
Returns
A new Iterator object pointing to the element at the updated position.

◆ operator==()

template<size_t D>
bool pfc::MultiIndex< D >::Iterator::operator== ( const Iterator other) const
inline

Compares two iterators for equality.

Parameters
otherThe iterator to compare.
Returns
True if the iterators are equal, false otherwise.

Friends And Related Symbol Documentation

◆ operator<<

template<size_t D>
std::ostream & operator<< ( std::ostream &  os,
const Iterator it 
)
friend

Outputs the current multi-dimensional indices to the specified output stream.

Parameters
osThe output stream.
itThe iterator to output.
Returns
Reference to the output stream.

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