tatami
C++ API for different matrix representations
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
tatami::SomeNumericArray< Value_ >::Iterator Struct Reference

Random-access iterator class. More...

#include <SomeNumericArray.hpp>

Public Types

using iterator_category = std::random_access_iterator_tag
 
using difference_type = std::ptrdiff_t
 
using value_type = Value_
 
using pointer = const Value_ *
 
using reference = const Value_ &
 

Public Member Functions

 Iterator ()
 
 Iterator (const SomeNumericArray *parent, size_t index)
 
value_type operator* () const
 
value_type operator[] (size_t i) const
 
bool operator== (const Iterator &right) const
 
bool operator!= (const Iterator &right) const
 
bool operator< (const Iterator &right) const
 
bool operator>= (const Iterator &right) const
 
bool operator> (const Iterator &right) const
 
bool operator<= (const Iterator &right) const
 
Iteratoroperator+= (size_t n)
 
Iteratoroperator++ ()
 
Iterator operator++ (int)
 
Iteratoroperator-= (size_t n)
 
Iteratoroperator-- ()
 
Iterator operator-- (int)
 
Iterator operator+ (size_t n) const
 
Iterator operator- (size_t n) const
 
std::ptrdiff_t operator- (const Iterator &right) const
 

Friends

Iterator operator+ (size_t n, const Iterator &it)
 

Detailed Description

template<typename Value_ = double>
struct tatami::SomeNumericArray< Value_ >::Iterator

Random-access iterator class.

This mimics the const iterators for std::vector types.

Member Typedef Documentation

◆ iterator_category

template<typename Value_ = double>
using tatami::SomeNumericArray< Value_ >::Iterator::iterator_category = std::random_access_iterator_tag

Random access iterator tag.

◆ difference_type

template<typename Value_ = double>
using tatami::SomeNumericArray< Value_ >::Iterator::difference_type = std::ptrdiff_t

Difference type.

◆ value_type

template<typename Value_ = double>
using tatami::SomeNumericArray< Value_ >::Iterator::value_type = Value_

Value type.

◆ pointer

template<typename Value_ = double>
using tatami::SomeNumericArray< Value_ >::Iterator::pointer = const Value_*

Pointer type, note the const.

◆ reference

template<typename Value_ = double>
using tatami::SomeNumericArray< Value_ >::Iterator::reference = const Value_&

Reference type, note the const.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

template<typename Value_ = double>
tatami::SomeNumericArray< Value_ >::Iterator::Iterator ( )
inline

Default constructor.

◆ Iterator() [2/2]

template<typename Value_ = double>
tatami::SomeNumericArray< Value_ >::Iterator::Iterator ( const SomeNumericArray parent,
size_t  index 
)
inline
Parameters
parentPointer to the parental SomeNumericArray object.
indexIndex along the parental array, representing the current position of the iterator.

Needless to say, we assume that the parental array outlives the iterator.

Member Function Documentation

◆ operator*()

template<typename Value_ = double>
value_type tatami::SomeNumericArray< Value_ >::Iterator::operator* ( ) const
inline
Returns
The value at the current position of the iterator on the parental SomeNumericArray object.

◆ operator[]()

template<typename Value_ = double>
value_type tatami::SomeNumericArray< Value_ >::Iterator::operator[] ( size_t  i) const
inline
Parameters
iThe number of elements to add to the current position of the iterator to obtain a new position.
Returns
The value at the new position on the parental SomeNumericArray object.

◆ operator==()

template<typename Value_ = double>
bool tatami::SomeNumericArray< Value_ >::Iterator::operator== ( const Iterator right) const
inline
Parameters
rightAnother Iterator object referencing the same parental array.
Returns
Whether the current iterator and right are pointing to the same position.

◆ operator!=()

template<typename Value_ = double>
bool tatami::SomeNumericArray< Value_ >::Iterator::operator!= ( const Iterator right) const
inline
Parameters
rightAnother Iterator object referencing the same parental array.
Returns
Whether the current iterator and right are pointing to different positions.

◆ operator<()

template<typename Value_ = double>
bool tatami::SomeNumericArray< Value_ >::Iterator::operator< ( const Iterator right) const
inline
Parameters
rightAnother Iterator object referencing the same parental array.
Returns
Whether the current iterator is pointing to an earlier position than right.

◆ operator>=()

template<typename Value_ = double>
bool tatami::SomeNumericArray< Value_ >::Iterator::operator>= ( const Iterator right) const
inline
Parameters
rightAnother Iterator object referencing the same parental array.
Returns
Whether the current iterator is pointing to an equal or later position than right.

◆ operator>()

template<typename Value_ = double>
bool tatami::SomeNumericArray< Value_ >::Iterator::operator> ( const Iterator right) const
inline
Parameters
rightAnother Iterator object referencing the same parental array.
Returns
Whether the current iterator is pointing to a later position than right.

◆ operator<=()

template<typename Value_ = double>
bool tatami::SomeNumericArray< Value_ >::Iterator::operator<= ( const Iterator right) const
inline
Parameters
rightAnother Iterator object referencing the same parental array.
Returns
Whether the current iterator is pointing to an equal or earlier position than right.

◆ operator+=()

template<typename Value_ = double>
Iterator & tatami::SomeNumericArray< Value_ >::Iterator::operator+= ( size_t  n)
inline
Parameters
nNumber of elements to advance the current iterator.
Returns
The iterator's position is moved forward by n, and a reference to the iterator is returned.

◆ operator++() [1/2]

template<typename Value_ = double>
Iterator & tatami::SomeNumericArray< Value_ >::Iterator::operator++ ( )
inline
Returns
The iterator's position is moved forward by 1, and a reference to the iterator is returned.

◆ operator++() [2/2]

template<typename Value_ = double>
Iterator tatami::SomeNumericArray< Value_ >::Iterator::operator++ ( int  )
inline
Returns
The position of the iterator is moved forward by 1, while a copy of the iterator (pre-increment) is returned.

◆ operator-=()

template<typename Value_ = double>
Iterator & tatami::SomeNumericArray< Value_ >::Iterator::operator-= ( size_t  n)
inline
Parameters
nNumber of elements to move back the current iterator.
Returns
The iterator's position is moved backward by n, and a reference to the iterator is returned.

◆ operator--() [1/2]

template<typename Value_ = double>
Iterator & tatami::SomeNumericArray< Value_ >::Iterator::operator-- ( )
inline
Returns
The iterator's position is moved backwards by 1, and a reference to the iterator is returned.

◆ operator--() [2/2]

template<typename Value_ = double>
Iterator tatami::SomeNumericArray< Value_ >::Iterator::operator-- ( int  )
inline
Returns
The position of the iterator is moved back by 1, while a copy of the iterator (pre-decrement) is returned.

◆ operator+()

template<typename Value_ = double>
Iterator tatami::SomeNumericArray< Value_ >::Iterator::operator+ ( size_t  n) const
inline
Parameters
nNumber of elements to advance the iterator.
Returns
A new iterator is returned at the position of the current iterator plus n.

◆ operator-() [1/2]

template<typename Value_ = double>
Iterator tatami::SomeNumericArray< Value_ >::Iterator::operator- ( size_t  n) const
inline
Parameters
nNumber of elements to move back the iterator.
Returns
A new iterator is returned at the position of the current iterator minus n.

◆ operator-() [2/2]

template<typename Value_ = double>
std::ptrdiff_t tatami::SomeNumericArray< Value_ >::Iterator::operator- ( const Iterator right) const
inline
Parameters
rightAnother Iterator object referencing the same parental array.
Returns
The difference in positions of the two iterators.

Friends And Related Symbol Documentation

◆ operator+

template<typename Value_ = double>
Iterator operator+ ( size_t  n,
const Iterator it 
)
friend
Parameters
nNumber of elements to advance the iterator.
itAn existing Iterator.
Returns
A new iterator is returned at the position of it plus n.

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