Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::DynMatrix< T >::Iterator Class Reference

Iterator for traversing matrix elements. More...

#include <tpl_dynMat.H>

Collaboration diagram for Aleph::DynMatrix< T >::Iterator:
[legend]

Public Types

using Set_Type = DynMatrix< T >
 The container type this iterator operates on.
 

Public Member Functions

 Iterator (const DynMatrix< T > &mat) noexcept
 Construct an iterator for a matrix.
 
bool has_curr () const noexcept
 Check if iterator has a current element.
 
const Tget_curr_ne () const noexcept
 Get the current element without bounds checking.
 
const Tget_curr () const
 Get the current element.
 
void next_ne () noexcept
 Advance to the next element without bounds checking.
 
void next ()
 Advance to the next element.
 
size_t get_row () const noexcept
 Get the current row index.
 
size_t get_col () const noexcept
 Get the current column index.
 
void reset () noexcept
 Reset iterator to the beginning.
 

Private Attributes

const DynMatrixmat_ptr = nullptr
 
size_t curr_idx = 0
 

Detailed Description

template<typename T>
class Aleph::DynMatrix< T >::Iterator

Iterator for traversing matrix elements.

Provides forward iteration over all matrix positions in row-major order. The iterator visits positions (0,0), (0,1), ..., (0,m-1), (1,0), ...

Note
This iterator visits all logical positions, not just written entries. Use the underlying DynArray iterator for sparse traversal.

Definition at line 598 of file tpl_dynMat.H.

Member Typedef Documentation

◆ Set_Type

template<typename T >
using Aleph::DynMatrix< T >::Iterator::Set_Type = DynMatrix<T>

The container type this iterator operates on.

Definition at line 606 of file tpl_dynMat.H.

Constructor & Destructor Documentation

◆ Iterator()

template<typename T >
Aleph::DynMatrix< T >::Iterator::Iterator ( const DynMatrix< T > &  mat)
inlinenoexcept

Construct an iterator for a matrix.

Parameters
[in]matThe matrix to iterate over.

Definition at line 612 of file tpl_dynMat.H.

Member Function Documentation

◆ get_col()

template<typename T >
size_t Aleph::DynMatrix< T >::Iterator::get_col ( ) const
inlinenoexcept

Get the current column index.

Returns
The column index of the current position.

Definition at line 673 of file tpl_dynMat.H.

References Aleph::DynMatrix< T >::Iterator::curr_idx, Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::Iterator::mat_ptr.

◆ get_curr()

template<typename T >
const T & Aleph::DynMatrix< T >::Iterator::get_curr ( ) const
inline

Get the current element.

Returns
Reference to the current element.
Exceptions
std::overflow_errorIf iterator is exhausted.

Definition at line 638 of file tpl_dynMat.H.

References ah_overflow_error_unless, Aleph::DynMatrix< T >::Iterator::get_curr_ne(), and Aleph::DynMatrix< T >::Iterator::has_curr().

◆ get_curr_ne()

template<typename T >
const T & Aleph::DynMatrix< T >::Iterator::get_curr_ne ( ) const
inlinenoexcept

Get the current element without bounds checking.

Returns
Reference to the current element.

Definition at line 628 of file tpl_dynMat.H.

References Aleph::DynMatrix< T >::Iterator::curr_idx, Aleph::DynMatrix< T >::Iterator::mat_ptr, and Aleph::DynMatrix< T >::read_array_entry().

Referenced by Aleph::DynMatrix< T >::Iterator::get_curr().

◆ get_row()

template<typename T >
size_t Aleph::DynMatrix< T >::Iterator::get_row ( ) const
inlinenoexcept

Get the current row index.

Returns
The row index of the current position.

Definition at line 664 of file tpl_dynMat.H.

References Aleph::DynMatrix< T >::Iterator::curr_idx, Aleph::DynMatrix< T >::m, and Aleph::DynMatrix< T >::Iterator::mat_ptr.

◆ has_curr()

template<typename T >
bool Aleph::DynMatrix< T >::Iterator::has_curr ( ) const
inlinenoexcept

Check if iterator has a current element.

Returns
true if positioned at a valid element, false otherwise.

Definition at line 619 of file tpl_dynMat.H.

References Aleph::DynMatrix< T >::Iterator::curr_idx, Aleph::DynMatrix< T >::Iterator::mat_ptr, and Aleph::DynMatrix< T >::size().

Referenced by Aleph::DynMatrix< T >::Iterator::get_curr(), and Aleph::DynMatrix< T >::Iterator::next().

◆ next()

template<typename T >
void Aleph::DynMatrix< T >::Iterator::next ( )
inline

Advance to the next element.

Exceptions
std::overflow_errorIf iterator is already exhausted.

Definition at line 653 of file tpl_dynMat.H.

References ah_overflow_error_unless, Aleph::DynMatrix< T >::Iterator::has_curr(), and Aleph::DynMatrix< T >::Iterator::next_ne().

◆ next_ne()

template<typename T >
void Aleph::DynMatrix< T >::Iterator::next_ne ( )
inlinenoexcept

Advance to the next element without bounds checking.

Definition at line 647 of file tpl_dynMat.H.

References Aleph::DynMatrix< T >::Iterator::curr_idx.

Referenced by Aleph::DynMatrix< T >::Iterator::next().

◆ reset()

template<typename T >
void Aleph::DynMatrix< T >::Iterator::reset ( )
inlinenoexcept

Reset iterator to the beginning.

Definition at line 680 of file tpl_dynMat.H.

References Aleph::DynMatrix< T >::Iterator::curr_idx.

Member Data Documentation

◆ curr_idx

◆ mat_ptr


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