Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::DynDlist< T >::Iterator Class Reference

Iterator dynamic list. More...

#include <tpl_dynDlist.H>

Inheritance diagram for Aleph::DynDlist< T >::Iterator:
[legend]
Collaboration diagram for Aleph::DynDlist< T >::Iterator:
[legend]

Public Types

using Set_Type = DynDlist
 The type of container.
 
using Item_Type = T
 The type of element stored in the container.
 
- Public Types inherited from Aleph::Dnode< T >::Iterator
using Set_Type = Dnode< T >
 The type of set.
 
using Item_Type = Dnode< T > *
 The type of element of set.
 
using Base = Dlink::Iterator
 

Public Member Functions

long get_pos () const noexcept
 Return the ordinal position of current item.
 
void next_ne () noexcept
 Move the iterator one position forward guaranteeing no exception.
 
void next ()
 Move the iterator one item forward.
 
void prev ()
 Move the iterator one item backward.
 
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 the iterator at the end state (where there is no current item)
 
 Iterator (const DynDlist< T > &list) noexcept
 Initialize the iterator to the first item of list
 
 Iterator () noexcept
 
Iteratoroperator= (const Iterator &it) noexcept
 
Tget_curr () const
 Return the current item; throw overflow_error if there is no current item.
 
Tget_curr_ne () const noexcept
 
void insert (const T &item)
 Insert by copy an item after the current item.
 
void insert (T &&item)
 Insert by movement an item after the current item.
 
void append (const T &item)
 Append by copy an item before the current item.
 
void append (T &&item)
 Append by movement an item after the current item.
 
void insert_list (DynDlist &list)
 Move and insert all elements of list after the current item of iterator.
 
void append_list (DynDlist &list)
 Move and append all elements of list before the current item of iterator.
 
T del ()
 Remove from the list the current node and move the iterator one position forward.
 
- Public Member Functions inherited from Aleph::Dnode< T >::Iterator
Dnode< T > * get_curr_ne () const noexcept
 Return the current link guaranteeing no exception. Be careful.
 
Dnode< T > * get_curr () const
 Return a pointer to the current node.
 
Dnodedel ()
 Remove the current node of the list a return a pointer to the removed node.
 
Dnodedel_ne () noexcept
 Same as del() but without exception check.
 

Private Types

using Base = typename Dnode< T >::Iterator
 

Private Attributes

DynDlistlist_ptr
 
long pos
 

Detailed Description

template<typename T = int>
class Aleph::DynDlist< T >::Iterator

Iterator dynamic list.

Definition at line 485 of file tpl_dynDlist.H.

Member Typedef Documentation

◆ Base

template<typename T = int>
using Aleph::DynDlist< T >::Iterator::Base = typename Dnode<T>::Iterator
private

Definition at line 490 of file tpl_dynDlist.H.

◆ Item_Type

template<typename T = int>
using Aleph::DynDlist< T >::Iterator::Item_Type = T

The type of element stored in the container.

Definition at line 498 of file tpl_dynDlist.H.

◆ Set_Type

template<typename T = int>
using Aleph::DynDlist< T >::Iterator::Set_Type = DynDlist

The type of container.

Definition at line 495 of file tpl_dynDlist.H.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

template<typename T = int>
Aleph::DynDlist< T >::Iterator::Iterator ( const DynDlist< T > &  list)
inlinenoexcept

Initialize the iterator to the first item of list

Definition at line 548 of file tpl_dynDlist.H.

◆ Iterator() [2/2]

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

Definition at line 554 of file tpl_dynDlist.H.

Member Function Documentation

◆ append() [1/2]

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

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

Definition at line 624 of file tpl_dynDlist.H.

References ah_overflow_error_if, Aleph::Dnode< T >::Iterator::get_curr(), Aleph::Dlink::Iterator::has_curr(), Aleph::DynDlist< T >::Iterator::list_ptr, FunctionalMethods< Container, T >::maps(), and Aleph::DynDlist< T >::num_elem.

Referenced by Aleph::DynDlist< T >::Iterator::append().

◆ append() [2/2]

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

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

Definition at line 643 of file tpl_dynDlist.H.

References ah_overflow_error_if, Aleph::DynDlist< T >::Iterator::append(), Aleph::Dnode< T >::Iterator::get_curr(), Aleph::Dlink::Iterator::has_curr(), Aleph::DynDlist< T >::Iterator::list_ptr, FunctionalMethods< Container, T >::maps(), and Aleph::DynDlist< T >::num_elem.

◆ append_list()

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

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

Definition at line 695 of file tpl_dynDlist.H.

References ah_overflow_error_if, Aleph::Dnode< T >::Iterator::get_curr(), Aleph::Dlink::Iterator::has_curr(), Aleph::Dlink::is_empty(), Aleph::DynDlist< T >::Iterator::list_ptr, FunctionalMethods< Container, T >::maps(), and Aleph::DynDlist< T >::num_elem.

◆ del()

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

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

Definition at line 713 of file tpl_dynDlist.H.

References ah_overflow_error_if, Aleph::Dlink::del(), Aleph::Dnode< T >::Iterator::get_curr(), Aleph::Dnode< T >::get_data(), Aleph::Dlink::Iterator::has_curr(), Aleph::DynDlist< T >::Iterator::list_ptr, FunctionalMethods< Container, T >::maps(), Aleph::Dlink::Iterator::next(), and Aleph::DynDlist< T >::num_elem.

◆ end()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::end ( )
inlinenoexcept

Put the iterator at the end state (where there is no current item)

Definition at line 542 of file tpl_dynDlist.H.

References put_itor_at_the_end().

◆ get_curr()

template<typename T = int>
T & Aleph::DynDlist< T >::Iterator::get_curr ( ) const
inline

Return the current item; throw overflow_error if there is no current item.

Definition at line 567 of file tpl_dynDlist.H.

References Aleph::Dnode< T >::Iterator::get_curr().

Referenced by Eepic_Plane::compute_extreme_points(), Aleph::Path< GT >::Iterator::get_curr_path_desc(), and Aleph::Path< GT >::get_last_arc().

◆ get_curr_ne()

template<typename T = int>
T & Aleph::DynDlist< T >::Iterator::get_curr_ne ( ) const
inlinenoexcept

◆ get_pos()

template<typename T = int>
long Aleph::DynDlist< T >::Iterator::get_pos ( ) const
inlinenoexcept

Return the ordinal position of current item.

Definition at line 501 of file tpl_dynDlist.H.

References Aleph::DynDlist< T >::Iterator::pos.

◆ insert() [1/2]

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

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

Definition at line 586 of file tpl_dynDlist.H.

References ah_overflow_error_if, Aleph::Dnode< T >::Iterator::get_curr(), Aleph::Dlink::Iterator::has_curr(), Aleph::DynDlist< T >::Iterator::list_ptr, FunctionalMethods< Container, T >::maps(), and Aleph::DynDlist< T >::num_elem.

Referenced by Aleph::DynDlist< T >::Iterator::insert().

◆ insert() [2/2]

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

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

Definition at line 605 of file tpl_dynDlist.H.

References ah_overflow_error_if, Aleph::Dnode< T >::Iterator::get_curr(), Aleph::Dlink::Iterator::has_curr(), Aleph::DynDlist< T >::Iterator::insert(), Aleph::DynDlist< T >::Iterator::list_ptr, FunctionalMethods< Container, T >::maps(), and Aleph::DynDlist< T >::num_elem.

◆ insert_list()

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

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

Definition at line 668 of file tpl_dynDlist.H.

References ah_overflow_error_if, Aleph::Dnode< T >::Iterator::get_curr(), Aleph::Dlink::Iterator::has_curr(), Aleph::Dlink::is_empty(), Aleph::DynDlist< T >::Iterator::list_ptr, FunctionalMethods< Container, T >::maps(), and Aleph::DynDlist< T >::num_elem.

◆ next()

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

Move the iterator one item forward.

Throw overflow_error if iterator has not current item

Definition at line 513 of file tpl_dynDlist.H.

References Aleph::Dlink::Iterator::next(), and Aleph::DynDlist< T >::Iterator::pos.

Referenced by Eepic_Plane::compute_extreme_points(), TYPED_TEST(), and TYPED_TEST().

◆ next_ne()

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

Move the iterator one position forward guaranteeing no exception.

Be careful.

Definition at line 505 of file tpl_dynDlist.H.

References Aleph::Dlink::Iterator::next_ne(), and Aleph::DynDlist< T >::Iterator::pos.

Referenced by Eepic_Plane::compute_extreme_points().

◆ operator=()

template<typename T = int>
Iterator & Aleph::DynDlist< T >::Iterator::operator= ( const Iterator it)
inlinenoexcept

◆ prev()

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

Move the iterator one item backward.

Throw underflow_error if iterator has not current item

Definition at line 521 of file tpl_dynDlist.H.

References Aleph::DynDlist< T >::Iterator::pos, and Aleph::Dlink::Iterator::prev().

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

◆ reset_first()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::reset_first ( )
inlinenoexcept

Reset the iterator to the first item.

Definition at line 528 of file tpl_dynDlist.H.

References Aleph::DynDlist< T >::Iterator::pos, and Aleph::Dlink::Iterator::reset_first().

◆ reset_last()

template<typename T = int>
void Aleph::DynDlist< T >::Iterator::reset_last ( )
inlinenoexcept

Member Data Documentation

◆ list_ptr

◆ pos


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