|
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 | set_pos (const long new_pos) noexcept |
Move the iterator to the logical position new_pos. | |
| 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:
Array_Iterator is a mutable value type with no shared state; it does not synchronize access to its own state (pos, idx, ...). Reading (e.g. is_last(), has_curr()) and mutating (e.g. next_ne(), reset_last(), set_pos()) the same instance concurrently from different threads without external synchronization is a data race. The usual "distinct objects,
distinct threads" rule applies.| T | Element type. |
Definition at line 84 of file array_it.H.
The type of elements being iterated.
Definition at line 119 of file array_it.H.
|
default |
Default constructor - creates an invalid iterator.
|
inline |
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 151 of file array_it.H.
References Aleph::blossom_maximum_cardinality_matching(), 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 168 of file array_it.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Array_Iterator< T >::dim, 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 190 of file array_it.H.
References ah_domain_error_if, Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::Array_Iterator< T >::dim, Aleph::Array_Iterator< T >::first, Aleph::Array_Iterator< T >::last, 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 212 of file array_it.H.
References Aleph::and, Aleph::blossom_maximum_cardinality_matching(), Aleph::Array_Iterator< T >::dim, Aleph::Array_Iterator< T >::first, Aleph::Array_Iterator< T >::last, Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::ptr.
|
inlineexplicit |
Construct an iterator from an Array_Container.
| c | Container to iterate over. |
Definition at line 224 of file array_it.H.
|
inlinenoexcept |
Put the iterator at the end (past the last item).
The end state is defined as the logical position num_items, so that get_pos() distances remain consistent for random-access adapters even when the container is empty (begin and end are both position 0).
Definition at line 363 of file array_it.H.
References Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::set_pos().
|
inlineconstexprnoexcept |
Get the base pointer of the array (const version).
Definition at line 132 of file array_it.H.
References Aleph::Array_Iterator< T >::ptr.
|
inlinenoexcept |
Get the base pointer of the array.
Definition at line 124 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 268 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(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Get the current item without bounds checking.
Definition at line 258 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 249 of file array_it.H.
References Aleph::Array_Iterator< T >::pos.
|
inlinenoexcept |
Check if there is a current valid item.
Definition at line 231 of file array_it.H.
References Aleph::and, Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::pos.
Referenced by Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::build_combinatorial_embedding_bruteforce(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::build_combinatorial_embedding_linear_lr(), Aleph::build_level_graph(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::build_nonplanar_certificate(), Aleph::capacity_scaling_maximum_flow(), Aleph::check_baseball_elimination(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::classify_k33(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::classify_k5(), Aleph::planarity_detail::collect_certificate_nodes(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::compute_faces_from_rotation(), compute_min_cut_capacity(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::count_components(), Aleph::decompose_flow(), Aleph::design_survey(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::fails_component_euler_bound(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::fill_certificate_paths(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::fill_embedding_result(), Aleph::hlpp_maximum_flow(), Aleph::Array_Iterator< T >::is_last(), Aleph::karp_minimum_mean_cycle(), Aleph::karp_minimum_mean_cycle_value(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::make_edge_witness(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::orient_dfs(), Aleph::planar_dual_metadata(), Aleph::planar_geometric_drawing(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::run_lr_planarity_test(), Aleph::segment_image(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::simple_edges_are_planar(), Aleph::MCF_LP_Solver< Net >::solve(), Aleph::solve_assignment(), Aleph::solve_circulation(), Aleph::solve_project_selection(), Aleph::ssp_shortest_path(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::planarity_detail::LR_Planarity_Checker< GT, SA >::test_dfs(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), Aleph::validate_nonplanar_certificate(), and verify_flow_conservation().
|
inlinenoexcept |
Check if positioned at the last item.
true only if there is a current item and it is the last one; false for empty or singular iterators. Definition at line 241 of file array_it.H.
References Aleph::and, Aleph::Array_Iterator< T >::has_curr(), Aleph::Array_Iterator< T >::num_items, and Aleph::Array_Iterator< T >::pos.
Referenced by TEST().
|
inline |
Advance to the next item with bounds checking.
| std::overflow_error | if already at or past the end. |
Definition at line 290 of file array_it.H.
References ah_overflow_error_if, Aleph::blossom_maximum_cardinality_matching(), 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 280 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 310 of file array_it.H.
References ah_underflow_error_if, Aleph::blossom_maximum_cardinality_matching(), 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 300 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 317 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 324 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 330 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(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
Move the iterator to the logical position new_pos.
Sets the logical position and recomputes the physical (possibly circular) index as idx = (first + new_pos) % dim. This mapping is consistent with the wraparound performed by next_ne()/prev_ne() and with the end state produced by end() (pos == num_items), enabling O(1) random-access positioning.
| [in] | new_pos | Logical position in [0, num_items], where num_items denotes the end state. |
new_pos outside [0, num_items] yields an iterator with no current item. Definition at line 350 of file array_it.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Array_Iterator< T >::dim, Aleph::Array_Iterator< T >::first, Aleph::Array_Iterator< T >::idx, and Aleph::Array_Iterator< T >::pos.
Referenced by Aleph::Array_Iterator< T >::end().
|
private |
Definition at line 87 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(), Aleph::Array_Iterator< T >::prev_ne(), and Aleph::Array_Iterator< T >::set_pos().
|
private |
Definition at line 90 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::Array_Iterator(), Aleph::Array_Iterator< T >::reset(), and Aleph::Array_Iterator< T >::set_pos().
|
private |
Definition at line 89 of file array_it.H.
Referenced by Aleph::Array_Iterator< T >::get_curr(), Aleph::Array_Iterator< T >::get_curr_ne(), Aleph::Array_Iterator< T >::next_ne(), Aleph::Array_Iterator< T >::prev_ne(), Aleph::Array_Iterator< T >::reset(), Aleph::Array_Iterator< T >::reset_last(), and Aleph::Array_Iterator< T >::set_pos().
|
private |
Definition at line 91 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 88 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 >::end(), 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 92 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(), Aleph::Array_Iterator< T >::reset_last(), and Aleph::Array_Iterator< T >::set_pos().
|
private |
Definition at line 86 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().