Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Euclid::NdArray::NdArray< T >::Iterator< Const > Class Template Reference

#include <NdArray.h>

Inheritance diagram for Euclid::NdArray::NdArray< T >::Iterator< Const >:
Inheritance graph
[legend]
Collaboration diagram for Euclid::NdArray::NdArray< T >::Iterator< Const >:
Collaboration graph
[legend]

Public Types

using value_t = typename std::conditional< Const, const T, T >::type
 

Public Member Functions

 Iterator (const Iterator< false > &other)
 
Iteratoroperator++ ()
 
const Iterator operator++ (int)
 
bool operator== (const Iterator &other) const
 
bool operator!= (const Iterator &other) const
 
value_toperator* ()
 
value_t operator* () const
 
Iteratoroperator+= (size_t n)
 
Iterator operator+ (size_t n) const
 
Iteratoroperator-= (size_t n)
 
Iterator operator- (size_t n) const
 
difference_type operator- (const Iterator &other)
 
value_toperator[] (size_t i)
 
value_t operator[] (size_t i) const
 
bool operator< (const Iterator &other)
 
bool operator> (const Iterator &other)
 

Private Member Functions

 Iterator (ContainerInterface *container_ptr, size_t offset, const std::vector< size_t > &shape, const std::vector< size_t > &strides, size_t start)
 
 Iterator (ContainerInterface *container_ptr, size_t offset, size_t row_size, size_t stride, size_t start)
 

Private Attributes

ContainerInterfacem_container_ptr
 
size_t m_offset
 
size_t m_row_size
 
size_t m_stride
 
size_t m_i
 

Friends

class NdArray
 

Detailed Description

template<typename T>
template<bool Const>
class Euclid::NdArray::NdArray< T >::Iterator< Const >

Iterator type

Template Parameters
ConstIf true, this defines a const iterator

Definition at line 62 of file NdArray.h.

Member Typedef Documentation

◆ value_t

template<typename T >
template<bool Const>
using Euclid::NdArray::NdArray< T >::Iterator< Const >::value_t = typename std::conditional<Const, const T, T>::type

Definition at line 79 of file NdArray.h.

Constructor & Destructor Documentation

◆ Iterator() [1/3]

template<typename T >
template<bool Const>
Euclid::NdArray::NdArray< T >::Iterator< Const >::Iterator ( ContainerInterface container_ptr,
size_t  offset,
const std::vector< size_t > &  shape,
const std::vector< size_t > &  strides,
size_t  start 
)
private

◆ Iterator() [2/3]

template<typename T >
template<bool Const>
Euclid::NdArray::NdArray< T >::Iterator< Const >::Iterator ( ContainerInterface container_ptr,
size_t  offset,
size_t  row_size,
size_t  stride,
size_t  start 
)
private

◆ Iterator() [3/3]

template<typename T >
template<bool Const>
Euclid::NdArray::NdArray< T >::Iterator< Const >::Iterator ( const Iterator< false > &  other)

Construct a const iterator from a non-const iterator

Member Function Documentation

◆ operator!=()

template<typename T >
template<bool Const>
bool Euclid::NdArray::NdArray< T >::Iterator< Const >::operator!= ( const Iterator< Const > &  other) const

Two iterators are not equal if they point to different data, or to different positions on the same

◆ operator*() [1/2]

template<typename T >
template<bool Const>
value_t & Euclid::NdArray::NdArray< T >::Iterator< Const >::operator* ( )

De-reference operator

Returns
A modifiable reference to the value

◆ operator*() [2/2]

template<typename T >
template<bool Const>
value_t Euclid::NdArray::NdArray< T >::Iterator< Const >::operator* ( ) const

De-reference operator

Returns
A non modifiable copy of the value

◆ operator+()

template<typename T >
template<bool Const>
Iterator Euclid::NdArray::NdArray< T >::Iterator< Const >::operator+ ( size_t  n) const
Returns
A new iterator incremented n times
Note
No out of bounds check is perform! Going beyond the end of the container is undefined behavior

◆ operator++() [1/2]

template<typename T >
template<bool Const>
Iterator & Euclid::NdArray::NdArray< T >::Iterator< Const >::operator++ ( )

Pre-increment

◆ operator++() [2/2]

template<typename T >
template<bool Const>
const Iterator Euclid::NdArray::NdArray< T >::Iterator< Const >::operator++ ( int  )

Post-increment

◆ operator+=()

template<typename T >
template<bool Const>
Iterator & Euclid::NdArray::NdArray< T >::Iterator< Const >::operator+= ( size_t  n)

Increment the iterator n times in place

Note
No out of bounds check is perform! Going beyond the end of the container is undefined behavior

◆ operator-() [1/2]

template<typename T >
template<bool Const>
difference_type Euclid::NdArray::NdArray< T >::Iterator< Const >::operator- ( const Iterator< Const > &  other)
Returns
The number of positions between this and other
Note
If this and other point to different underlying data, this is undefined behavior

◆ operator-() [2/2]

template<typename T >
template<bool Const>
Iterator Euclid::NdArray::NdArray< T >::Iterator< Const >::operator- ( size_t  n) const
Returns
A new iterator incremented n times
Note
There is an assert in place to make sure n is not greater than the current position. However, the assert can be gone when compiling for release

◆ operator-=()

template<typename T >
template<bool Const>
Iterator & Euclid::NdArray::NdArray< T >::Iterator< Const >::operator-= ( size_t  n)

Decrement the iterator n times in place

Note
There is an assert in place to make sure n is not greater than the current position. However, the assert can be gone when compiling for release

◆ operator<()

template<typename T >
template<bool Const>
bool Euclid::NdArray::NdArray< T >::Iterator< Const >::operator< ( const Iterator< Const > &  other)
Returns
true if this is less than other
Note
If this and other point to different underlying data, this is undefined behavior

◆ operator==()

template<typename T >
template<bool Const>
bool Euclid::NdArray::NdArray< T >::Iterator< Const >::operator== ( const Iterator< Const > &  other) const

Two iterators are equal if they point to the same position on the same data

◆ operator>()

template<typename T >
template<bool Const>
bool Euclid::NdArray::NdArray< T >::Iterator< Const >::operator> ( const Iterator< Const > &  other)
Returns
true if this is greater than other
Note
If this and other point to different underlying data, this is undefined behavior

◆ operator[]() [1/2]

template<typename T >
template<bool Const>
value_t & Euclid::NdArray::NdArray< T >::Iterator< Const >::operator[] ( size_t  i)

Equivalent to *(iterator + i)

◆ operator[]() [2/2]

template<typename T >
template<bool Const>
value_t Euclid::NdArray::NdArray< T >::Iterator< Const >::operator[] ( size_t  i) const

Equivalent to *(iterator + i)

Friends And Related Symbol Documentation

◆ NdArray

template<typename T >
template<bool Const>
friend class NdArray
friend

Definition at line 76 of file NdArray.h.

Member Data Documentation

◆ m_container_ptr

template<typename T >
template<bool Const>
ContainerInterface* Euclid::NdArray::NdArray< T >::Iterator< Const >::m_container_ptr
private

Definition at line 65 of file NdArray.h.

◆ m_i

template<typename T >
template<bool Const>
size_t Euclid::NdArray::NdArray< T >::Iterator< Const >::m_i
private

Definition at line 69 of file NdArray.h.

◆ m_offset

template<typename T >
template<bool Const>
size_t Euclid::NdArray::NdArray< T >::Iterator< Const >::m_offset
private

Definition at line 66 of file NdArray.h.

◆ m_row_size

template<typename T >
template<bool Const>
size_t Euclid::NdArray::NdArray< T >::Iterator< Const >::m_row_size
private

Definition at line 67 of file NdArray.h.

◆ m_stride

template<typename T >
template<bool Const>
size_t Euclid::NdArray::NdArray< T >::Iterator< Const >::m_stride
private

Definition at line 68 of file NdArray.h.


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