Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Const_Iterator< It > Class Template Reference

Read-only view of an Aleph iterator: the iterator of a constant container. More...

#include <ah-iterator.H>

Inheritance diagram for Aleph::Const_Iterator< It >:
[legend]
Collaboration diagram for Aleph::Const_Iterator< It >:
[legend]

Public Types

using Itor = It
 The underlying iterator.
 
using aleph_random_access_iterator = std::conditional_t< AlephRandomAccessItor< It >, Const_Iterator, void >
 Random access when the underlying iterator opts in; see AlephRandomAccessItor.
 

Public Member Functions

 Const_Iterator ()=default
 A view with no current item.
 
template<class C >
requires (not std::same_as<std::remove_cvref_t<C>, Const_Iterator> and not std::same_as<std::remove_cvref_t<C>, It>)
 Const_Iterator (const C &c)
 View positioned on the first item of the container c.
 
 Const_Iterator (It underlying) noexcept(std::is_nothrow_move_constructible_v< It >)
 Read-only view over an existing iterator.
 
template<class I = It>
auto has_curr () const noexcept(noexcept(std::declval< I & >().has_curr())) -> decltype(std::declval< I & >().has_curr())
 true if there is a current item.
 
template<class I = It>
auto get_curr () const noexcept(noexcept(std::declval< I & >().get_curr())) -> const_iterator_detail::const_item_t< decltype(std::declval< I & >().get_curr())>
 The current item, read-only.
 
template<class I = It>
auto get_curr_ne () const noexcept(noexcept(std::declval< I & >().get_curr_ne())) -> const_iterator_detail::const_item_t< decltype(std::declval< I & >().get_curr_ne())>
 get_curr() without the checks of the underlying iterator.
 
template<class I = It>
auto next () noexcept(noexcept(std::declval< I & >().next())) -> decltype(std::declval< I & >().next())
 Move to the next item; what the underlying iterator throws.
 
template<class I = It>
auto next_ne () noexcept(noexcept(std::declval< I & >().next_ne())) -> decltype(std::declval< I & >().next_ne())
 next() without checks.
 
template<class I = It>
auto prev () noexcept(noexcept(std::declval< I & >().prev())) -> decltype(std::declval< I & >().prev())
 Move to the previous item; what the underlying iterator throws.
 
template<class I = It>
auto prev_ne () noexcept(noexcept(std::declval< I & >().prev_ne())) -> decltype(std::declval< I & >().prev_ne())
 prev() without checks.
 
template<class I = It>
auto reset_first () noexcept(noexcept(std::declval< I & >().reset_first())) -> decltype(std::declval< I & >().reset_first())
 Position the view on the first item.
 
template<class I = It>
auto reset_last () noexcept(noexcept(std::declval< I & >().reset_last())) -> decltype(std::declval< I & >().reset_last())
 Position the view on the last item.
 
template<class I = It>
auto reset () noexcept(noexcept(std::declval< I & >().reset())) -> decltype(std::declval< I & >().reset())
 Position the view on the first item.
 
template<class I = It>
auto end () noexcept(noexcept(std::declval< I & >().end())) -> decltype(std::declval< I & >().end())
 Position the view past the last item.
 
template<class I = It>
auto get_pos () const noexcept(noexcept(std::declval< I & >().get_pos())) -> decltype(std::declval< I & >().get_pos())
 Ordinal position of the current item.
 
template<class I = It>
auto set_pos (const long pos) noexcept(noexcept(std::declval< I & >().set_pos(pos))) -> decltype(std::declval< I & >().set_pos(pos))
 Position the view on the item at ordinal position pos.
 
template<class I = It>
auto is_last () const noexcept(noexcept(std::declval< I & >().is_last())) -> decltype(std::declval< I & >().is_last())
 true if the current item is the last one.
 
template<class I = It>
auto is_in_first () const noexcept(noexcept(std::declval< I & >().is_in_first())) -> decltype(std::declval< I & >().is_in_first())
 true if the current item is the first one.
 
template<class I = It>
auto is_in_last () const noexcept(noexcept(std::declval< I & >().is_in_last())) -> decltype(std::declval< I & >().is_in_last())
 true if the current item is the last one.
 
void swap (Const_Iterator &other) noexcept(std::is_nothrow_swappable_v< It >)
 Exchange the views.
 
template<class I = It>
auto operator== (const Const_Iterator &other) const -> decltype(std::declval< I & >()==std::declval< I & >())
 Equality of the underlying iterators, when they have it.
 
template<class I = It>
auto operator!= (const Const_Iterator &other) const -> decltype(not(std::declval< I & >()==std::declval< I & >()))
 Negation of ==.
 

Protected Member Functions

It & underlying () const noexcept
 The underlying iterator, for the views that extend the reading protocol with members of their own (the read-only iterators of the graphs do it with get_src_node() and get_tgt_node()).
 

Static Private Member Functions

template<class C >
static It make (const C &c)
 

Private Attributes

It it
 

Detailed Description

template<class It>
class Aleph::Const_Iterator< It >

Read-only view of an Aleph iterator: the iterator of a constant container.

Const_Iterator<It> wraps the iterator It of a container and exposes its reading protocol (has_curr(), get_curr(), next(), prev(), reset_first(), get_pos()...) and nothing else: get_curr() hands out the current item as a reference to const (a pointer to const for the iterators that hand out pointers), and the members that modify the container through the iterator (del(), set(), insert()...) do not exist. It is what get_it() returns on a constant container, and the const_iterator of the STL interface of every container. Each member exists only when the underlying iterator has it, and so do the typedefs Item_Type and Set_Type.

The underlying iterator is built from the constant container through a constructor that accepts it when the iterator has one (DynArray keeps one, so that the view never allocates); otherwise through a const_cast that stays harmless, because the view exposes nothing modifiable.

Template Parameters
Itthe iterator of the container.
See also
const_iterator_t iterator_for StlConstIterator

Definition at line 336 of file ah-iterator.H.

Member Typedef Documentation

◆ aleph_random_access_iterator

template<class It >
using Aleph::Const_Iterator< It >::aleph_random_access_iterator = std::conditional_t<AlephRandomAccessItor<It>, Const_Iterator, void>

Random access when the underlying iterator opts in; see AlephRandomAccessItor.

Definition at line 364 of file ah-iterator.H.

◆ Itor

template<class It >
using Aleph::Const_Iterator< It >::Itor = It

The underlying iterator.

Definition at line 361 of file ah-iterator.H.

Constructor & Destructor Documentation

◆ Const_Iterator() [1/3]

template<class It >
Aleph::Const_Iterator< It >::Const_Iterator ( )
default

A view with no current item.

◆ Const_Iterator() [2/3]

template<class It >
template<class C >
requires (not std::same_as<std::remove_cvref_t<C>, Const_Iterator> and not std::same_as<std::remove_cvref_t<C>, It>)
Aleph::Const_Iterator< It >::Const_Iterator ( const C &  c)
inlineexplicit

View positioned on the first item of the container c.

Parameters
[in]cthe container; it is never modified through the view.

Definition at line 376 of file ah-iterator.H.

◆ Const_Iterator() [3/3]

template<class It >
Aleph::Const_Iterator< It >::Const_Iterator ( It  underlying)
inlineexplicitnoexcept

Read-only view over an existing iterator.

Parameters
[in]underlyingthe iterator; the view starts at its position.

Definition at line 381 of file ah-iterator.H.

Member Function Documentation

◆ end()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::end ( ) -> decltype(std::declval<I &>().end())
inlinenoexcept

Position the view past the last item.

Definition at line 465 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by TEST().

◆ get_curr()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::get_curr ( ) const -> const_iterator_detail::const_item_t<decltype(std::declval<I &>().get_curr())>
inlinenoexcept

The current item, read-only.

Returns
a reference to const (a pointer to const for the iterators that hand out pointers).
Exceptions
whatget_curr() of the underlying iterator throws.

Definition at line 398 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by Aleph::Path< GT >::Iterator::get_curr_path_desc(), Aleph::Path< GT >::get_last_arc(), Aleph::is_inversely_sorted(), Aleph::is_sorted(), Aleph::search_extreme(), Aleph::search_inversion(), TEST(), and Aleph::test_sorted().

◆ get_curr_ne()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::get_curr_ne ( ) const -> const_iterator_detail::const_item_t<decltype(std::declval<I &>().get_curr_ne())>
inlinenoexcept

get_curr() without the checks of the underlying iterator.

Definition at line 406 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by Aleph::Path< GT >::Iterator::get_curr_path_desc_ne(), and TEST().

◆ get_pos()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::get_pos ( ) const -> decltype(std::declval<I &>().get_pos())
inlinenoexcept

Ordinal position of the current item.

Definition at line 472 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by StlConstIterator< SetType >::operator==(), and TEST().

◆ has_curr()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::has_curr ( ) const -> decltype(std::declval<I &>().has_curr())
inlinenoexcept

true if there is a current item.

Definition at line 386 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by Aleph::Const_Graph_View< GT >::adjacent_nodes(), Aleph::Const_Graph_View< GT >::arcs(), Aleph::Const_Graph_View< GT >::arcs(), Aleph::Const_Graph_View< GT >::arcs_map(), Aleph::Tarjan_Connected_Components< GT, Itor, SA >::build_path(), Aleph::Const_Graph_View< GT >::count_arcs(), Aleph::Const_Graph_View< GT >::count_nodes(), demo_any_path(), demo_degrees_of_separation(), EqualSequenceMethod< Container >::equal_to(), EqualSortedMethod< Container >::equal_to(), Aleph::Const_Graph_View< GT >::filter_arcs(), Aleph::Const_Graph_View< GT >::filter_arcs(), Aleph::Const_Graph_View< GT >::filter_nodes(), Aleph::Const_Graph_View< GT >::foldl_arcs(), Aleph::Const_Graph_View< GT >::foldl_nodes(), Aleph::Const_Graph_View< GT >::for_each_arc(), Aleph::Const_Graph_View< GT >::for_each_arc(), Aleph::Const_Graph_View< GT >::for_each_node(), Aleph::generate_dot_file(), Aleph::Path< GT >::Iterator::has_current_arc(), Aleph::Path< GT >::Iterator::has_current_node(), imprimir_camino(), Aleph::is_inversely_sorted(), Aleph::is_sorted(), Aleph::Const_Graph_View< GT >::nodes(), Aleph::Const_Graph_View< GT >::nodes_map(), path_edge_count(), print_grid_with_path(), Aleph::Const_Graph_View< GT >::search_arc(), Aleph::Const_Graph_View< GT >::search_arc(), Aleph::Const_Graph_View< GT >::search_arc(), Aleph::search_extreme(), Aleph::search_inversion(), Aleph::Const_Graph_View< GT >::search_node(), Aleph::sequential_search(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::test_sorted(), Aleph::Const_Graph_View< GT >::traverse_arcs(), Aleph::Const_Graph_View< GT >::traverse_arcs(), Aleph::Const_Graph_View< GT >::traverse_nodes(), TYPED_TEST(), TYPED_TEST(), TYPED_TEST(), and TYPED_TEST().

◆ is_in_first()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::is_in_first ( ) const -> decltype(std::declval<I &>().is_in_first())
inlinenoexcept

true if the current item is the first one.

Definition at line 496 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

◆ is_in_last()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::is_in_last ( ) const -> decltype(std::declval<I &>().is_in_last())
inlinenoexcept

true if the current item is the last one.

Definition at line 504 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by Aleph::Path< GT >::Iterator::get_current_arc(), Aleph::Path< GT >::Iterator::has_current_arc(), and TEST().

◆ is_last()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::is_last ( ) const -> decltype(std::declval<I &>().is_last())
inlinenoexcept

true if the current item is the last one.

Definition at line 488 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

◆ make()

template<class It >
template<class C >
static It Aleph::Const_Iterator< It >::make ( const C &  c)
inlinestaticprivate

Definition at line 343 of file ah-iterator.H.

◆ next()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::next ( ) -> decltype(std::declval<I &>().next())
inlinenoexcept

Move to the next item; what the underlying iterator throws.

Definition at line 414 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by TEST(), TYPED_TEST(), and TYPED_TEST().

◆ next_ne()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::next_ne ( ) -> decltype(std::declval<I &>().next_ne())
inlinenoexcept

◆ operator!=()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::operator!= ( const Const_Iterator< It > &  other) const -> decltype(not (std::declval<I &>() == std::declval<I &>()))
inline

Negation of ==.

Definition at line 527 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

◆ operator==()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::operator== ( const Const_Iterator< It > &  other) const -> decltype(std::declval<I &>() == std::declval<I &>())
inline

Equality of the underlying iterators, when they have it.

Definition at line 519 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

◆ prev()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::prev ( ) -> decltype(std::declval<I &>().prev())
inlinenoexcept

Move to the previous item; what the underlying iterator throws.

Definition at line 428 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by Aleph::Path< GT >::get_last_arc(), and TEST().

◆ prev_ne()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::prev_ne ( ) -> decltype(std::declval<I &>().prev_ne())
inlinenoexcept

prev() without checks.

Definition at line 435 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

◆ reset()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::reset ( ) -> decltype(std::declval<I &>().reset())
inlinenoexcept

Position the view on the first item.

Definition at line 458 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

◆ reset_first()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::reset_first ( ) -> decltype(std::declval<I &>().reset_first())
inlinenoexcept

Position the view on the first item.

Definition at line 442 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by TEST().

◆ reset_last()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::reset_last ( ) -> decltype(std::declval<I &>().reset_last())
inlinenoexcept

Position the view on the last item.

Definition at line 450 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by Aleph::Path< GT >::get_last_arc(), and TEST().

◆ set_pos()

template<class It >
template<class I = It>
auto Aleph::Const_Iterator< It >::set_pos ( const long  pos) -> decltype(std::declval<I &>().set_pos(pos))
inlinenoexcept

Position the view on the item at ordinal position pos.

Definition at line 480 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Referenced by Aleph::DynArray< T >::get_it().

◆ swap()

template<class It >
void Aleph::Const_Iterator< It >::swap ( Const_Iterator< It > &  other)
inlinenoexcept

Exchange the views.

Definition at line 511 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it, and Aleph::Const_Iterator< It >::swap().

Referenced by Aleph::Const_Iterator< It >::swap(), and TEST().

◆ underlying()

template<class It >
It & Aleph::Const_Iterator< It >::underlying ( ) const
inlineprotectednoexcept

The underlying iterator, for the views that extend the reading protocol with members of their own (the read-only iterators of the graphs do it with get_src_node() and get_tgt_node()).

Returns
a reference to the underlying iterator.

Definition at line 357 of file ah-iterator.H.

References Aleph::Const_Iterator< It >::it.

Member Data Documentation

◆ it


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