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

Filtered iterator for incoming arcs of a node. More...

#include <tpl_graph.H>

Inheritance diagram for Aleph::In_Iterator< GT, SA >:
[legend]
Collaboration diagram for Aleph::In_Iterator< GT, SA >:
[legend]

Public Types

using Item_Type = typename GT::Arc *
 
- Public Types inherited from Aleph::Digraph_Iterator< GT, __In_Filt< GT > >
using Item_Type = typename Itor::Item_Type
 
using Iterator_Type = Itor
 The type of element.
 

Public Member Functions

 In_Iterator ()=default
 
 In_Iterator (typename GT::Node *p, SA sa=SA())
 Iterator on the arcs of the list of p whose target is p and that sa shows.
 
 In_Iterator (const GT &g, typename GT::Node *p, SA sa=SA())
 Iterator on the arcs of g into p that sa shows; on a graph of an undirected type, those of the list of p.
 
void next ()
 
void next_ne () noexcept(NothrowPredicateWith< SA &, typename GT::Arc * >)
 next() without the check of the current arc; noexcept when the filter is, else what the filter throws goes out
 
void prev ()
 Move to the previous arc that the filter shows.
 
- Public Member Functions inherited from Aleph::Digraph_Iterator< GT, __In_Filt< GT > >
 Digraph_Iterator (typename GT::Node *p)
 Initialize an iterator on adjacent arcs (incoming or outcoming) of p
 
void next ()
 Move the iterator one position forward.
 
void next_ne () noexcept(shows_ne)
 next() without its check: the current arc must exist.
 
void prev ()
 Move the iterator one position backward.
 
bool has_curr () const noexcept
 Return true the iterator has an current arc.
 
GT::Arc * get_curr () const
 Return the current arc.
 
GT::Arc * get_curr_ne () const noexcept
 Return the current arc.
 
auto get_current_arc () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Alias for get_curr().
 
GT::Node * get_node (typename GT::Arc *a) const noexcept
 Return the connected node to arc.
 
GT::Node * get_node () const
 Return the connected node to current arc.
 
auto get_tgt_node () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Alias for get_node().
 
GT::Node * get_node_ne () const noexcept
 Return the connected node to current arc.
 
auto get_tgt_node_ne () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Alias for get_node_ne().
 
void reset_first () noexcept(shows_ne)
 Reset the iterator to the first arc.
 
void reset_last () noexcept(shows_ne)
 Reset the iterator to the last arc.
 
void end () noexcept(shows_ne)
 Put the iterator in end state.
 

Private Types

using Base = Digraph_Iterator< GT, __In_Filt< GT > >
 

Private Member Functions

void goto_first_valid ()
 
void goto_last_valid ()
 

Static Private Member Functions

static void refuse_a_digraph ()
 
static GT::Node * of_lists (const GT &g, typename GT::Node *p)
 

Private Attributes

SA show_arc
 

Additional Inherited Members

- Static Public Attributes inherited from Aleph::Digraph_Iterator< GT, __In_Filt< GT > >
static constexpr bool goes_back
 Iterator type.
 
static constexpr bool goes_to_last
 Whether the iterator goes to its last arc, which reset_last() and end() need.
 
static constexpr bool shows_ne
 Whether what the filter says of an arc cannot throw, nor its conversion to bool: the moves without checks and the resets are noexcept then.
 

Detailed Description

template<class GT, class SA = Dft_Show_Arc<GT>>
class Aleph::In_Iterator< GT, SA >

Filtered iterator for incoming arcs of a node.

This iterator traverses the incoming arcs of a node, those whose target is the node, optionally filtered by the Show_Arc predicate.

A digraph keeps each arc only in the list of its source, while a graph that is not directed keeps it in the lists of both ends, so that the iterator has two forms:

  • In_Iterator(g, p, sa) takes the graph. On a digraph type (DigraphType) it walks the arcs of g and keeps those whose target is p and that sa shows, in the order of the arc iterator of g: to build it and go through all of them takes \(O(E)\). On a graph that is not directed it walks the list of p, as the other form; it throws domain_error on a graph of an undirected type that says that it is directed (see set_digraph()), whose arcs into p are not in the list of p.
  • In_Iterator(p, sa) walks the list of p. It does not compile on a digraph type, whose list of p holds only the arcs that leave p. It cannot tell a graph of an undirected type that says that it is directed, on which it sees only the loops of p.

The functions on the arcs into a node that take the graph, as in_arcs(g, p) and in_degree(g, p), tell a digraph at run time, also of an undirected type. To go through the arcs into many nodes of a digraph, build an In_Arcs_Index once, in \(O(V + E)\).

prev() and reset_last() exist only where the iterators of the graph move back: not on List_SGraph and List_SDigraph.

Template Parameters
GTThe graph type
SAArc filter predicate (default shows all arcs)
See also
In_Arcs_Index DigraphType

Definition at line 2044 of file tpl_graph.H.

Member Typedef Documentation

◆ Base

template<class GT , class SA = Dft_Show_Arc<GT>>
using Aleph::In_Iterator< GT, SA >::Base = Digraph_Iterator<GT, __In_Filt<GT> >
private

Definition at line 2046 of file tpl_graph.H.

◆ Item_Type

template<class GT , class SA = Dft_Show_Arc<GT>>
using Aleph::In_Iterator< GT, SA >::Item_Type = typename GT::Arc *

Definition at line 2082 of file tpl_graph.H.

Constructor & Destructor Documentation

◆ In_Iterator() [1/3]

template<class GT , class SA = Dft_Show_Arc<GT>>
Aleph::In_Iterator< GT, SA >::In_Iterator ( )
default

◆ In_Iterator() [2/3]

template<class GT , class SA = Dft_Show_Arc<GT>>
Aleph::In_Iterator< GT, SA >::In_Iterator ( typename GT::Node *  p,
SA  sa = SA() 
)
inline

Iterator on the arcs of the list of p whose target is p and that sa shows.

The list holds the arcs into p only in a graph that is not directed: on a digraph type it does not compile.

Parameters
[in]pthe node.
[in]sathe arc filter.

Definition at line 2093 of file tpl_graph.H.

References Aleph::In_Iterator< GT, SA >::goto_first_valid().

◆ In_Iterator() [3/3]

template<class GT , class SA = Dft_Show_Arc<GT>>
Aleph::In_Iterator< GT, SA >::In_Iterator ( const GT &  g,
typename GT::Node *  p,
SA  sa = SA() 
)
inline

Iterator on the arcs of g into p that sa shows; on a graph of an undirected type, those of the list of p.

It is inlined, as the form that takes only the node is, so that it costs on a graph that is not directed only the test of g.is_digraph().

Parameters
[in]gthe graph of p.
[in]pthe node.
[in]sathe arc filter.
Exceptions
domain_errorif g says that it is directed.

Definition at line 2111 of file tpl_graph.H.

Member Function Documentation

◆ goto_first_valid()

◆ goto_last_valid()

◆ next()

template<class GT , class SA = Dft_Show_Arc<GT>>
void Aleph::In_Iterator< GT, SA >::next ( )
inline

◆ next_ne()

template<class GT , class SA = Dft_Show_Arc<GT>>
void Aleph::In_Iterator< GT, SA >::next_ne ( )
inlinenoexcept

next() without the check of the current arc; noexcept when the filter is, else what the filter throws goes out

Definition at line 2125 of file tpl_graph.H.

References Aleph::In_Iterator< GT, SA >::goto_first_valid(), and Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::next_ne().

◆ of_lists()

template<class GT , class SA = Dft_Show_Arc<GT>>
static GT::Node * Aleph::In_Iterator< GT, SA >::of_lists ( const GT &  g,
typename GT::Node *  p 
)
inlinestaticprivate

◆ prev()

template<class GT , class SA = Dft_Show_Arc<GT>>
void Aleph::In_Iterator< GT, SA >::prev ( )
inline

Move to the previous arc that the filter shows.

Only where the iterator moves back: not on List_SGraph

Definition at line 2133 of file tpl_graph.H.

References Aleph::In_Iterator< GT, SA >::goto_last_valid(), and Aleph::Digraph_Iterator< GT, __In_Filt< GT > >::prev().

◆ refuse_a_digraph()

template<class GT , class SA = Dft_Show_Arc<GT>>
static void Aleph::In_Iterator< GT, SA >::refuse_a_digraph ( )
inlinestaticprivate

Definition at line 2064 of file tpl_graph.H.

References ah_domain_error.

Referenced by Aleph::In_Iterator< GT, SA >::of_lists().

Member Data Documentation

◆ show_arc

template<class GT , class SA = Dft_Show_Arc<GT>>
SA Aleph::In_Iterator< GT, SA >::show_arc
private

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