Aleph-w  1.9
General library for algorithms and data structures
Aleph::Path< GT >::Iterator Class Reference

#include <tpl_graph.H>

+ Inheritance diagram for Aleph::Path< GT >::Iterator:
+ Collaboration diagram for Aleph::Path< GT >::Iterator:

Public Types

using Set_Type = DynDlist
 The type of container.
 
using Item_Type = T
 The type of element stored in the container.
 

Public Member Functions

 Iterator (const Path &path) noexcept
 Create an iterator on the first node of path
 
Node * get_current_node () const
 
Node * get_current_node_ne () const noexcept
 
Arc * get_current_arc () const
 
Arc * get_current_arc_ne () const noexcept
 
Node * get_curr_ne () const noexcept
 
Node * get_curr () const
 
pair< Node *, Arc * > get_pair () const
 
tuple< Node *, Arc * > get_tuple () const
 
tuple< Node *, Arc * > get_tuple_ne () const noexcept
 
bool has_current_arc () const noexcept
 
bool has_current_node () const noexcept
 Return true if the iterator has a current node.
 
long get_pos () const noexcept
 Return the ordinal position of current item.
 
void next_ne () noexcept
 
void next ()
 
void prev ()
 
void reset_first () noexcept
 Reset the iterator to the first item.
 
void reset_last () noexcept
 Reset the iterator to the last item.
 
void end () noexcept
 Put theiterator at the end state (where there is no current item)
 
void insert (const T &item)
 
void insert (T &&item)
 
void append (const T &item)
 
void append (T &&item)
 
void insert_list (DynDlist &list)
 
void append_list (DynDlist &list)
 
del ()
 
void set (Dlink *new_curr) noexcept
 
bool has_curr () const noexcept
 Return true if the iterator has current item.
 
bool is_last () const noexcept
 
bool is_in_first () const noexcept
 Return true if the iterator is positiones on the first item.
 
bool is_in_last () const noexcept
 Return true if the iterator is positiones on the last item.
 
void prev_ne () noexcept
 
bool operator== (const Iterator &it) const noexcept
 Return true if this and it are positioned on the same item.
 
bool operator!= (const Iterator &it) const noexcept
 Return true if this and it hace different states.
 
Dlinkdel_ne () noexcept
 
bool verify (Dlink *l) const
 Return true if the iterator is on the list pointed by l
 
bool verify (const Iterator &it) const
 Return true if this and it are on the same list.
 

Detailed Description

template<class GT>
class Aleph::Path< GT >::Iterator

Iterator on nodes and arcs of a path

See also
Path

Member Function Documentation

◆ append() [1/2]

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::append ( const T &  item)
inlineinherited

Append by copy an item before the current item.

This method appends a copy of item before the current item of iterator. The current item is not moved.

Parameters
[in]itemthe item to append
Exceptions
bad_allocif there is no enough memory
overflow_errorif there is no current item
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append() [2/2]

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::append ( T &&  item)
inlineinherited

Append by movement an item after the current item.

This method appends a new element in the list before the current and then item is moved. The current item is not moved.

Parameters
[in]itemthe item to append
Exceptions
bad_allocif there is no enough memory
overflow_errorif there is no current item
+ Here is the call graph for this function:

◆ append_list()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::append_list ( DynDlist list)
inlineinherited

Move and append all elements of list before the current item of iterator.

This operation takes constant time and puts the element of list just before the current item. The current item of iterator is not moved. A prev() operation will move forward the iterator to the last item of list.

After operation list becomes empty, since all its items were moved to the list on which one is iterating.

Parameters
[in,out]listto append after current item. It becomes empty.
Exceptions
overflow_errorif there is no current item
+ Here is the call graph for this function:

◆ del()

template<typename T = int>
T Aleph::DynDlist< T >::Iterator::del ( )
inlineinherited

Remove from the list the current node and move the iterator one position forward.

Returns
a copy to removed item
Exceptions
overflow_errorif there is no current item
+ Here is the call graph for this function:

◆ get_curr_ne()

template<class GT>
Node* Aleph::Path< GT >::Iterator::get_curr_ne ( ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get_current_arc()

template<class GT>
Arc* Aleph::Path< GT >::Iterator::get_current_arc ( ) const
inline

Return the current arc of path.

Note
A path of n nodes has n - 1 arcs. So if the iterator is pistioned on the last node, the get_current_arc() has not current arc and will throw exception.
Returns
pointer to the current arc
Exceptions
overflow_errorif path is empty of iterator has not current node

◆ get_current_node()

template<class GT>
Node* Aleph::Path< GT >::Iterator::get_current_node ( ) const
inline

Return the current node of path. Throw overflow_error if path is empty of iterator has not current node

◆ get_pair()

template<class GT>
pair<Node*, Arc*> Aleph::Path< GT >::Iterator::get_pair ( ) const
inline

Return a pair with the current node and arc

Note
If the iterator is positioned on the last node, then its arc is nullptr.
Returns
a pair whose first element is the current node and second element its outcoming arc
Exceptions
overflow_errorif path is empty of iterator has not current node

◆ get_tuple()

template<class GT>
tuple<Node*, Arc*> Aleph::Path< GT >::Iterator::get_tuple ( ) const
inline

Return a tuple with the current node and arc

Note
If the iterator is positioned on the last node, then its arc is nullptr.
Returns
a tuple whose first element is the current node and second element its outcoming arc
Exceptions
overflow_errorif path is empty of iterator has not current node

◆ has_current_arc()

template<class GT>
bool Aleph::Path< GT >::Iterator::has_current_arc ( ) const
inlinenoexcept

Return true if iterator has current arc.

Note
If the iterator is on the last node, then there is no current arc.
Returns
a boolean indicating if the iterator is positioned on an arc
+ Here is the caller graph for this function:

◆ insert() [1/2]

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::insert ( const T &  item)
inlineinherited

Insert by copy an item after the current item.

This method inserts a copy of item after the current item of iterator. The current item is not moved.

Parameters
[in]itemthe item to insert
Exceptions
bad_allocif there is no enough memory
overflow_errorif there is no current item
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert() [2/2]

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::insert ( T &&  item)
inlineinherited

Insert by movement an item after the current item.

This method inserts a new element in the list after the current and then item is moved. The current item is not moved.

Parameters
[in]itemthe item to insert
Exceptions
bad_allocif there is no enough memory
overflow_errorif there is no current item
+ Here is the call graph for this function:

◆ insert_list()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::insert_list ( DynDlist list)
inlineinherited

Move and insert all elements of list after the current item of iterator.

This operation takes constant time and puts the element of list just after the current item. The current item of iterator is not moved. A next() operation will move forward the iterator to the first item of list.

After operation list becomes empty, since all its items were moved to the list on which one is iterating.

Parameters
[in,out]listto insert after current item. It becomes empty.
Exceptions
overflow_errorif there is no current item
+ Here is the call graph for this function:

◆ next()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::next ( )
inlineinherited

Move the iterator one item forward. Throw overflow_error if iterator has not current item

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ next_ne()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::next_ne ( )
inlinenoexceptinherited

Move the iterator one position forward guaranteeing no exception. Be careful.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prev()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::prev ( )
inlineinherited

Move the iterator one item backward. Throw underflow_error if iterator has not current item

+ Here is the call graph for this function:

◆ prev_ne()

void Aleph::Dlink::Iterator::prev_ne ( )
inlinenoexceptinherited

Move the iterator one position backward guaranteeing no exception. Be careful.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

void Aleph::Dlink::Iterator::set ( Dlink new_curr)
inlinenoexceptinherited

Set the current node .

This method set the current node to new_curr, which of course must be a valid pointer to a item in the list.

Parameters
[in]new_currpointer to the new current item
+ Here is the caller graph for this function:

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

Leandro Rabindranath León