TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
nda::array_iterator< 1, T, Pointer >

#include <nda/iterators.hpp>

Detailed Description

template<typename T, typename Pointer>
class nda::array_iterator< 1, T, Pointer >

Specialization of nda::array_iterator for 1-dimensional grids.

It is a LegacyRandomAccessIterator.

Template Parameters
TType of the elements in the array (can be const).
PointerType of the pointer used to access the elements in the array (might be restricted depending on the accessor).

Definition at line 321 of file iterators.hpp.

Public Types

using difference_type = std::ptrdiff_t
 Difference type.
 
using iterator_category = std::random_access_iterator_tag
 Iterator category.
 
using pointer = T *
 Pointer type.
 
using reference = T &
 Reference type.
 
using value_type = T
 Value type.
 

Public Member Functions

 array_iterator ()=default
 Default constructor leaves the iterator in an uninitialized state.
 
 array_iterator (std::array< long, 1 > const &lengths, std::array< long, 1 > const &strides, T *start, bool at_end)
 Construct an iterator from the shape and the strides of an array/view, a pointer to its data and a flag indicating if the iterator is at the end.
 
auto indices ()
 Get the current position/index of the iterator.
 
bool operator!= (array_iterator const &rhs) const
 Not-equal-to operator.
 
T & operator* () const
 Dereference operator.
 
array_iteratoroperator++ ()
 Prefix increment operator.
 
array_iterator operator++ (int)
 Postfix increment operator.
 
array_iteratoroperator+= (std::ptrdiff_t n)
 Compound assignment addition operator increments the iterator a given number of times.
 
array_iteratoroperator-- ()
 Prefix decrement operator.
 
array_iterator operator-- (int)
 Postfix decrement operator.
 
array_iteratoroperator-= (std::ptrdiff_t n)
 Compound assignment subtraction operator decrements the iterator a given number of times.
 
T & operator-> () const
 Member access operator.
 
bool operator== (array_iterator const &rhs) const
 Equal-to operator.
 
T & operator[] (std::ptrdiff_t n)
 Subscript operator.
 

Friends

array_iterator operator+ (array_iterator it, std::ptrdiff_t n)
 Binary addition of an 1-dimensional array iterator with an integer.
 
array_iterator operator+ (std::ptrdiff_t n, array_iterator it)
 Binary addition of an integer with an 1-dimensional array iterator.
 
std::ptrdiff_t operator- (array_iterator const &lhs, array_iterator const &rhs)
 Binary subtraction of two 1-dimensional array iterators.
 
array_iterator operator- (array_iterator it, std::ptrdiff_t n)
 Binary subtraction of an 1-dimensional array iterator with an integer.
 
bool operator< (array_iterator const &lhs, array_iterator const &rhs)
 Less-than comparison operator for two 1-dimensional array iterators.
 
bool operator<= (array_iterator const &lhs, array_iterator const &rhs)
 Less-than or equal-to comparison operator for two 1-dimensional array iterators.
 
bool operator> (array_iterator const &lhs, array_iterator const &rhs)
 Greater-than comparison operator for two 1-dimensional array iterators.
 
bool operator>= (array_iterator const &lhs, array_iterator const &rhs)
 Greater-than or equal-to comparison operator for two 1-dimensional array iterators.
 

Constructor & Destructor Documentation

◆ array_iterator()

template<typename T , typename Pointer >
nda::array_iterator< 1, T, Pointer >::array_iterator ( std::array< long, 1 > const & lengths,
std::array< long, 1 > const & strides,
T * start,
bool at_end )
inline

Construct an iterator from the shape and the strides of an array/view, a pointer to its data and a flag indicating if the iterator is at the end.

Parameters
lengthsShape of the array/view.
stridesStride of the array/view.
startPointer to the data.
at_endFlag indicating if the iterator is at the end.

Definition at line 362 of file iterators.hpp.

Member Function Documentation

◆ indices()

template<typename T , typename Pointer >
auto nda::array_iterator< 1, T, Pointer >::indices ( )
inlinenodiscard

Get the current position/index of the iterator.

Returns
std::array<long, 1> containing the current position/index of the iterator.

Definition at line 369 of file iterators.hpp.

◆ operator!=()

template<typename T , typename Pointer >
bool nda::array_iterator< 1, T, Pointer >::operator!= ( array_iterator< 1, T, Pointer > const & rhs) const
inlinenodiscard

Not-equal-to operator.

Parameters
rhsRight hand side operand.
Returns
True if the positions of the iterators are not equal, false otherwise.

Definition at line 433 of file iterators.hpp.

◆ operator*()

template<typename T , typename Pointer >
T & nda::array_iterator< 1, T, Pointer >::operator* ( ) const
inlinenodiscard

Dereference operator.

Returns
Reference to the element at the position of the iterator.

Definition at line 375 of file iterators.hpp.

◆ operator++() [1/2]

template<typename T , typename Pointer >
array_iterator & nda::array_iterator< 1, T, Pointer >::operator++ ( )
inline

Prefix increment operator.

Returns
Reference to the current iterator.

Definition at line 387 of file iterators.hpp.

◆ operator++() [2/2]

template<typename T , typename Pointer >
array_iterator nda::array_iterator< 1, T, Pointer >::operator++ ( int )
inline

Postfix increment operator.

Returns
Copy of the current iterator.

Definition at line 396 of file iterators.hpp.

◆ operator+=()

template<typename T , typename Pointer >
array_iterator & nda::array_iterator< 1, T, Pointer >::operator+= ( std::ptrdiff_t n)
inline

Compound assignment addition operator increments the iterator a given number of times.

Parameters
nNumber of times to increment the iterator.
Returns
Reference to the current iterator.

Definition at line 441 of file iterators.hpp.

◆ operator--() [1/2]

template<typename T , typename Pointer >
array_iterator & nda::array_iterator< 1, T, Pointer >::operator-- ( )
inline

Prefix decrement operator.

Returns
Reference to the current iterator.

Definition at line 406 of file iterators.hpp.

◆ operator--() [2/2]

template<typename T , typename Pointer >
array_iterator nda::array_iterator< 1, T, Pointer >::operator-- ( int )
inline

Postfix decrement operator.

Returns
Copy of the current iterator.

Definition at line 415 of file iterators.hpp.

◆ operator-=()

template<typename T , typename Pointer >
array_iterator & nda::array_iterator< 1, T, Pointer >::operator-= ( std::ptrdiff_t n)
inline

Compound assignment subtraction operator decrements the iterator a given number of times.

Parameters
nNumber of times to decrement the iterator.
Returns
Reference to the current iterator.

Definition at line 452 of file iterators.hpp.

◆ operator->()

template<typename T , typename Pointer >
T & nda::array_iterator< 1, T, Pointer >::operator-> ( ) const
inline

Member access operator.

Returns
Reference to the element at the position of the iterator.

Definition at line 381 of file iterators.hpp.

◆ operator==()

template<typename T , typename Pointer >
bool nda::array_iterator< 1, T, Pointer >::operator== ( array_iterator< 1, T, Pointer > const & rhs) const
inlinenodiscard

Equal-to operator.

Parameters
rhsRight hand side operand.
Returns
True if the positions of the iterators are equal, false otherwise.

Definition at line 426 of file iterators.hpp.

◆ operator[]()

template<typename T , typename Pointer >
T & nda::array_iterator< 1, T, Pointer >::operator[] ( std::ptrdiff_t n)
inlinenodiscard

Subscript operator.

Parameters
nNumber of times to increment the iterator before dereferencing it.
Returns
Reference to the element at the position of the incremented iterator.

Definition at line 499 of file iterators.hpp.

Friends And Related Symbol Documentation

◆ operator+ [1/2]

template<typename T , typename Pointer >
array_iterator operator+ ( array_iterator< 1, T, Pointer > it,
std::ptrdiff_t n )
friend

Binary addition of an 1-dimensional array iterator with an integer.

Parameters
it1-dimensional array iterator.
nInteger.
Returns
Array iterator incremented n times.

Definition at line 473 of file iterators.hpp.

◆ operator+ [2/2]

template<typename T , typename Pointer >
array_iterator operator+ ( std::ptrdiff_t n,
array_iterator< 1, T, Pointer > it )
friend

Binary addition of an integer with an 1-dimensional array iterator.

Parameters
nInteger.
it1-dimensional array iterator.
Returns
Array iterator incremented n times.

Definition at line 464 of file iterators.hpp.

◆ operator- [1/2]

template<typename T , typename Pointer >
std::ptrdiff_t operator- ( array_iterator< 1, T, Pointer > const & lhs,
array_iterator< 1, T, Pointer > const & rhs )
friend

Binary subtraction of two 1-dimensional array iterators.

Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
Difference between their positions.

Definition at line 491 of file iterators.hpp.

◆ operator- [2/2]

template<typename T , typename Pointer >
array_iterator operator- ( array_iterator< 1, T, Pointer > it,
std::ptrdiff_t n )
friend

Binary subtraction of an 1-dimensional array iterator with an integer.

Parameters
it1-dimensional array iterator.
nInteger.
Returns
Array iterator decremented n times.

Definition at line 482 of file iterators.hpp.

◆ operator<

template<typename T , typename Pointer >
bool operator< ( array_iterator< 1, T, Pointer > const & lhs,
array_iterator< 1, T, Pointer > const & rhs )
friend

Less-than comparison operator for two 1-dimensional array iterators.

Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
True if the position of the left hand side iterator is less than the position of the right hand side iterator, false otherwise.

Definition at line 510 of file iterators.hpp.

◆ operator<=

template<typename T , typename Pointer >
bool operator<= ( array_iterator< 1, T, Pointer > const & lhs,
array_iterator< 1, T, Pointer > const & rhs )
friend

Less-than or equal-to comparison operator for two 1-dimensional array iterators.

Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
True if the position of the left hand side iterator is less than or equal to the position of the right hand side iterator, false otherwise.

Definition at line 530 of file iterators.hpp.

◆ operator>

template<typename T , typename Pointer >
bool operator> ( array_iterator< 1, T, Pointer > const & lhs,
array_iterator< 1, T, Pointer > const & rhs )
friend

Greater-than comparison operator for two 1-dimensional array iterators.

Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
True if the position of the left hand side iterator is greater than the position of the right hand side iterator, false otherwise.

Definition at line 520 of file iterators.hpp.

◆ operator>=

template<typename T , typename Pointer >
bool operator>= ( array_iterator< 1, T, Pointer > const & lhs,
array_iterator< 1, T, Pointer > const & rhs )
friend

Greater-than or equal-to comparison operator for two 1-dimensional array iterators.

Parameters
lhsLeft hand side operand.
rhsRight hand side operand.
Returns
True if the position of the left hand side iterator is greater than or equal to the position of the right hand side iterator, false otherwise.

Definition at line 540 of file iterators.hpp.


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