|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Iterator wrapper for C++ raw arrays. More...
#include <array_it.H>
Public Types | |
| using | Item_Type = T |
| The type of elements being iterated. | |
Public Member Functions | |
| T * | get_base () noexcept |
| Get the base pointer of the array. | |
| constexpr const T * | get_base () const noexcept |
| Get the base pointer of the array (const version). | |
| Array_Iterator ()=default | |
| Default constructor - creates an invalid iterator. | |
| Array_Iterator (T *p, const size_t sz, const size_t n) | |
| Construct an iterator over an array. | |
| Array_Iterator (NoExceptionCtor, T *p, const size_t sz, const size_t n) | |
| Construct an iterator without exception checking. | |
| Array_Iterator (T *p, const size_t sz, const size_t n, const long f, const long l) | |
| Construct an iterator over a circular array region. | |
| Array_Iterator (NoExceptionCtor, T *p, const size_t sz, const size_t n, const long f, const long l) | |
| Construct a circular iterator without exception checking. | |
| Array_Iterator (const Array_Container< T > &c) | |
| Construct an iterator from an Array_Container. | |
| bool | has_curr () const noexcept |
| Check if there is a current valid item. | |
| bool | is_last () const noexcept |
| Check if positioned at the last item. | |
| constexpr long | get_pos () const noexcept |
| Get the current position index. | |
| T & | get_curr_ne () const noexcept |
| Get the current item without bounds checking. | |
| T & | get_curr () const |
| Get the current item with bounds checking. | |
| void | next_ne () noexcept |
| Advance to the next item without bounds checking. | |
| void | next () |
| Advance to the next item with bounds checking. | |
| void | prev_ne () noexcept |
| Move to the previous item without bounds checking. | |
| void | prev () |
| Move to the previous item with bounds checking. | |
| void | reset () noexcept |
| Reset the iterator to the first item. | |
| void | reset_first () noexcept |
| Reset the iterator to the first item (alias for reset()). | |
| void | reset_last () noexcept |
| Reset the iterator to the last item. | |
| void | end () noexcept |
| Put the iterator at the end (past the last item). | |
Private Attributes | |
| T * | ptr = nullptr |
| long | dim = 0 |
| long | num_items = 0 |
| long | idx = 0 |
| long | first = 0 |
| long | last = 0 |
| long | pos = 0 |
Iterator wrapper for C++ raw arrays.
Provides a full iterator interface for raw C arrays, including support for circular buffers where the logical sequence wraps around the physical array boundaries.
The iterator supports:
| T | Element type. |
Definition at line 76 of file array_it.H.
The type of elements being iterated.
Definition at line 114 of file array_it.H.
|
default |
Default constructor - creates an invalid iterator.
Construct an iterator over an array.
Creates an iterator for elements [0, n) in an array of size sz.
| p | Pointer to the array. |
| sz | Physical size of the array. |
| n | Number of valid items (logical size). |
| std::invalid_argument | if p is null but sz > 0. |
| std::domain_error | if n > sz. |
Definition at line 140 of file array_it.H.
References Aleph::maps(), and Aleph::Array_Iterator< T >::ptr.
|
inline |
Construct an iterator without exception checking.
Same as the regular constructor but performs assertions instead of throwing exceptions. Use only when you are certain the parameters are valid.
| p | Pointer to the array. |
| sz | Physical size of the array. |
| n | Number of valid items. |
Definition at line 157 of file array_it.H.
References Aleph::Array_Iterator< T >::dim, Aleph::maps(), Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::ptr.
|
inline |
Construct an iterator over a circular array region.
Creates an iterator for a circular array where the logical sequence starts at index f and ends at index l, possibly wrapping around the array boundaries.
| p | Pointer to the array. |
| sz | Physical size of the array. |
| n | Number of valid items. |
| f | First index (starting position). |
| l | Last index (ending position). |
| std::invalid_argument | if p is null but sz > 0. |
| std::domain_error | if parameters are inconsistent. |
Definition at line 179 of file array_it.H.
References ah_domain_error_if, Aleph::Array_Iterator< T >::dim, Aleph::Array_Iterator< T >::first, Aleph::Array_Iterator< T >::last, Aleph::maps(), Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::ptr.
|
inline |
Construct a circular iterator without exception checking.
| p | Pointer to the array. |
| sz | Physical size of the array. |
| n | Number of valid items. |
| f | First index. |
| l | Last index. |
Definition at line 201 of file array_it.H.
References Aleph::Array_Iterator< T >::dim, Aleph::Array_Iterator< T >::first, Aleph::Array_Iterator< T >::last, Aleph::maps(), Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::ptr.
|
inline |
Construct an iterator from an Array_Container.
| c | Container to iterate over. |
Definition at line 213 of file array_it.H.
|
inlinenoexcept |
Put the iterator at the end (past the last item).
Definition at line 314 of file array_it.H.
References put_itor_at_the_end().
|
inlineconstexprnoexcept |
Get the base pointer of the array (const version).
Definition at line 124 of file array_it.H.
References Aleph::Array_Iterator< T >::ptr.
|
inlinenoexcept |
Get the base pointer of the array.
Definition at line 119 of file array_it.H.
References Aleph::Array_Iterator< T >::ptr.
|
inline |
Get the current item with bounds checking.
| std::underflow_error | if positioned before the first item. |
| std::overflow_error | if positioned past the last item. |
Definition at line 245 of file array_it.H.
References ah_overflow_error_if, ah_underflow_error_if, Aleph::Array_Iterator< T >::idx, Aleph::Array_Iterator< T >::num_items, Aleph::Array_Iterator< T >::pos, and Aleph::Array_Iterator< T >::ptr.
Referenced by TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Get the current item without bounds checking.
Definition at line 235 of file array_it.H.
References Aleph::Array_Iterator< T >::idx, and Aleph::Array_Iterator< T >::ptr.
|
inlineconstexprnoexcept |
Get the current position index.
Definition at line 229 of file array_it.H.
References Aleph::Array_Iterator< T >::pos.
|
inlinenoexcept |
Check if there is a current valid item.
Definition at line 219 of file array_it.H.
References Aleph::maps(), Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::pos.
Referenced by Aleph::build_level_graph(), Aleph::capacity_scaling_maximum_flow(), Aleph::check_baseball_elimination(), compute_min_cut_capacity(), Aleph::decompose_flow(), Aleph::design_survey(), Aleph::hlpp_maximum_flow(), Aleph::segment_image(), Aleph::solve_assignment(), Aleph::solve_project_selection(), Aleph::ssp_shortest_path(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Check if positioned at the last item.
Definition at line 224 of file array_it.H.
References Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::pos.
|
inline |
Advance to the next item with bounds checking.
| std::overflow_error | if already at or past the end. |
Definition at line 269 of file array_it.H.
References ah_overflow_error_if, Aleph::maps(), Aleph::Array_Iterator< T >::next_ne(), Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::pos.
Referenced by TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Advance to the next item without bounds checking.
Definition at line 259 of file array_it.H.
References Aleph::Array_Iterator< T >::dim, Aleph::Array_Iterator< T >::idx, and Aleph::Array_Iterator< T >::pos.
Referenced by Aleph::Array_Iterator< T >::next().
|
inline |
Move to the previous item with bounds checking.
| std::underflow_error | if already at or before the beginning. |
Definition at line 289 of file array_it.H.
References ah_underflow_error_if, Aleph::maps(), Aleph::Array_Iterator< T >::num_items, Aleph::Array_Iterator< T >::pos, and Aleph::Array_Iterator< T >::prev_ne().
Referenced by TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Move to the previous item without bounds checking.
Definition at line 279 of file array_it.H.
References Aleph::Array_Iterator< T >::dim, Aleph::Array_Iterator< T >::idx, and Aleph::Array_Iterator< T >::pos.
Referenced by Aleph::Array_Iterator< T >::prev().
|
inlinenoexcept |
Reset the iterator to the first item.
Definition at line 297 of file array_it.H.
References Aleph::Array_Iterator< T >::first, Aleph::Array_Iterator< T >::idx, and Aleph::Array_Iterator< T >::pos.
Referenced by Aleph::Array_Iterator< T >::reset_first(), TEST(), TEST(), and TEST_F().
|
inlinenoexcept |
Reset the iterator to the first item (alias for reset()).
Definition at line 304 of file array_it.H.
References Aleph::Array_Iterator< T >::reset().
Referenced by TEST_F().
|
inlinenoexcept |
Reset the iterator to the last item.
Definition at line 307 of file array_it.H.
References Aleph::Array_Iterator< T >::idx, Aleph::Array_Iterator< T >::last, Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::pos.
Referenced by TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
private |
Definition at line 79 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::next_ne(), and Aleph::Array_Iterator< T >::prev_ne().
|
private |
Definition at line 82 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), and Aleph::Array_Iterator< T >::reset().
|
private |
|
private |
Definition at line 83 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), and Aleph::Array_Iterator< T >::reset_last().
|
private |
Definition at line 80 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::get_curr(), Aleph::Array_Iterator< T >::has_curr(), Aleph::Array_Iterator< T >::is_last(), Aleph::Array_Iterator< T >::next(), Aleph::Array_Iterator< T >::prev(), and Aleph::Array_Iterator< T >::reset_last().
|
private |
Definition at line 84 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::get_curr(), Aleph::Array_Iterator< T >::get_pos(), Aleph::Array_Iterator< T >::has_curr(), Aleph::Array_Iterator< T >::is_last(), Aleph::Array_Iterator< T >::next(), Aleph::Array_Iterator< T >::next_ne(), Aleph::Array_Iterator< T >::prev(), Aleph::Array_Iterator< T >::prev_ne(), Aleph::Array_Iterator< T >::reset(), and Aleph::Array_Iterator< T >::reset_last().
Definition at line 78 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::get_base(), Aleph::Array_Iterator< T >::get_base(), Aleph::Array_Iterator< T >::get_curr(), and Aleph::Array_Iterator< T >::get_curr_ne().