Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator Class Reference

Iterator on nodes of the tree. More...

#include <tpl_treapRk.H>

Collaboration diagram for Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator:
[legend]

Public Member Functions

 Iterator () noexcept
 
 Iterator (const Gen_Treap_Rk &__tree) noexcept
 Initialize an iterator on __tree
 
 Iterator (const Gen_Treap_Rk &__tree, Node *__curr) noexcept
 Initialize an iterator starting from node __curr
 
 Iterator (const Gen_Treap_Rk &__tree, const size_t pos) noexcept
 Initialize an iterator starting from the inorder position pos.
 
 Iterator (const Iterator &itor) noexcept
 
Iterator & operator= (const Iterator &itor) noexcept
 
void reset_first () noexcept
 Reset the iterator to the first position.
 
void reset_last () noexcept
 Reset the iterator to the last position.
 
void end () noexcept
 Put the iterator in the end state.
 
void reset_to_key (const Key &key) noexcept(noexcept(tree_ptr->find_position(key)))
 Put the iterator on the node of a key.
 
void reset_to_node (Node *node) noexcept
 Put the current node to a specific node.
 
void reset_to_pos (const size_t pos) noexcept
 Put the iterator on the inorder position pos.
 
Node * get_curr_ne () const noexcept
 Return the current node.
 
Node * get_curr () const noexcept
 Return the current node.
 
size_t get_current_position () const
 return the position of current node
 
size_t get_pos () const
 See get_current_position().
 
bool has_curr () const noexcept(nothrow_compare_v< Compare, Key >)
 Return true if the iterator has a current node.
 
void prev ()
 Move the iterator one position backward.
 
void next_ne () noexcept
 Move the iterator one position forward, without the check of next().
 
void next ()
 Move the iterator one position forward.
 
Node * del ()
 Remove the current node and move the iterator one position forward.
 
bool operator== (const Iterator &itor) const noexcept(nothrow_compare_v< Compare, Key >)
 Return true if this and itor are on the same position.
 
bool operator!= (const Iterator &itor) const
 Return true if this is not equal to itor
 
bool verify (Gen_Treap_Rk *r) const noexcept
 
bool verify (const Iterator &it) const noexcept
 

Protected Attributes

Gen_Treap_Rk * tree_ptr
 
Node * curr
 
int curr_pos
 

Static Protected Attributes

static constexpr int Pos_Not_Current = -1
 
static constexpr int Pos_Empty_Container = -2
 
static constexpr int Pos_Not_Updated = -3
 
static constexpr int Pos_Out_Of_Range = std::numeric_limits<int>::min()
 

Private Member Functions

bool is_container_empty () const noexcept
 
bool pos_updated () const noexcept
 
bool curr_updated () const noexcept
 
bool is_updated () const noexcept
 
void update_pos () const noexcept(nothrow_compare_v< Compare, Key >)
 
void update_curr () const noexcept
 

Static Private Member Functions

static int saturated_pos (const size_t pos) noexcept
 

Detailed Description

template<template< class > class NodeType, class Key, class Compare>
class Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator

Iterator on nodes of the tree.

The visit order is inorder.

Definition at line 947 of file tpl_treapRk.H.

Constructor & Destructor Documentation

◆ Iterator() [1/5]

template<template< class > class NodeType, class Key , class Compare >
Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Iterator ( )
inlinenoexcept

Definition at line 1032 of file tpl_treapRk.H.

◆ Iterator() [2/5]

template<template< class > class NodeType, class Key , class Compare >
Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Iterator ( const Gen_Treap_Rk &  __tree)
inlinenoexcept

◆ Iterator() [3/5]

template<template< class > class NodeType, class Key , class Compare >
Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Iterator ( const Gen_Treap_Rk &  __tree,
Node *  __curr 
)
inlinenoexcept

Initialize an iterator starting from node __curr

Definition at line 1046 of file tpl_treapRk.H.

◆ Iterator() [4/5]

template<template< class > class NodeType, class Key , class Compare >
Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Iterator ( const Gen_Treap_Rk &  __tree,
const size_t  pos 
)
inlinenoexcept

Initialize an iterator starting from the inorder position pos.

Parameters
[in]__treethe tree to iterate
[in]posinorder position; at size() or past it, the iterator is at the end, without current node, even if an int cannot hold it.

Definition at line 1060 of file tpl_treapRk.H.

◆ Iterator() [5/5]

template<template< class > class NodeType, class Key , class Compare >
Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Iterator ( const Iterator &  itor)
inlinenoexcept

Definition at line 1067 of file tpl_treapRk.H.

Member Function Documentation

◆ curr_updated()

◆ del()

◆ end()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::end ( )
inlinenoexcept

Put the iterator in the end state.

Definition at line 1101 of file tpl_treapRk.H.

References put_itor_at_the_end().

◆ get_curr()

template<template< class > class NodeType, class Key , class Compare >
Node * Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr ( ) const
inlinenoexcept

Return the current node.

Returns
the current node, or nullptr if there is none.
See also
get_curr_ne()

Definition at line 1177 of file tpl_treapRk.H.

References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr_ne().

◆ get_curr_ne()

template<template< class > class NodeType, class Key , class Compare >
Node * Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr_ne ( ) const
inlinenoexcept

Return the current node.

A position past the end has no node, whichever way the iterator got there: then it gives nullptr, without the check of select(), which would throw. A node that the iterator already found stays its current one, though: if the tree changes, as when keys before it are removed, it may give that node while has_curr() is false. A change of the tree invalidates the iterator, which must then be put on a position again.

Returns
the current node, or nullptr if there is none.

Definition at line 1164 of file tpl_treapRk.H.

References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_updated(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr().

Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_curr().

◆ get_current_position()

template<template< class > class NodeType, class Key , class Compare >
size_t Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_current_position ( ) const
inline

◆ get_pos()

template<template< class > class NodeType, class Key , class Compare >
size_t Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_pos ( ) const
inline

◆ has_curr()

template<template< class > class NodeType, class Key , class Compare >
bool Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr ( ) const
inlinenoexcept

Return true if the iterator has a current node.

Returns
true if the position of the iterator has a node.
Exceptions
anythingthat the comparison throws while it computes the position of a node that the iterator was put on, as reset_to_node() does. It is noexcept only if the comparison cannot throw, so that what it throws reaches the caller.

Definition at line 1213 of file tpl_treapRk.H.

References Aleph::and, Aleph::COUNT(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::getRoot(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::pos_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().

Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::del(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::prev().

◆ is_container_empty()

◆ is_updated()

template<template< class > class NodeType, class Key , class Compare >
bool Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_updated ( ) const
inlineprivatenoexcept

◆ next()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next ( )
inline

Move the iterator one position forward.

Throws overflow_error if there is no current

Definition at line 1247 of file tpl_treapRk.H.

References ah_underflow_error_if, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next_ne().

◆ next_ne()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next_ne ( )
inlinenoexcept

Move the iterator one position forward, without the check of next().

Past the end it goes on to positions without node. It adds 1 as an unsigned: from the greatest int, which a position given near it reaches past the end, it goes to Pos_Out_Of_Range, the least int, instead of overflowing.

Definition at line 1239 of file tpl_treapRk.H.

References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos.

Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::next().

◆ operator!=()

template<template< class > class NodeType, class Key , class Compare >
bool Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator!= ( const Iterator &  itor) const
inline

Return true if this is not equal to itor

Definition at line 1301 of file tpl_treapRk.H.

◆ operator=()

template<template< class > class NodeType, class Key , class Compare >
Iterator & Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator= ( const Iterator &  itor)
inlinenoexcept

◆ operator==()

template<template< class > class NodeType, class Key , class Compare >
bool Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::operator== ( const Iterator &  itor) const
inlinenoexcept

Return true if this and itor are on the same position.

Parameters
[in]itorthe iterator to compare with.
Returns
true if both iterators are on the same position.
Exceptions
anythingthat the comparison throws while it computes the position of a node that an iterator was put on. It is noexcept only if the comparison cannot throw, so that what it throws reaches the caller.

Definition at line 1277 of file tpl_treapRk.H.

References Aleph::and, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_updated(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_container_empty(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::pos_updated(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().

◆ pos_updated()

◆ prev()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::prev ( )
inline

◆ reset_first()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_first ( )
inlinenoexcept

◆ reset_last()

◆ reset_to_key()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_key ( const Key &  key)
inlinenoexcept

Put the iterator on the node of a key.

The node that the iterator had is dropped, so that get_curr() gives the node of the new position, not the previous one.

Parameters
[in]keyto guide the position; if it is not in the tree, the position is the one that find_position() gives.
Exceptions
anythingthat find_position() throws, as what the comparison or its copy throws; then the iterator is left as it was. It is noexcept only if find_position() is.

Definition at line 1117 of file tpl_treapRk.H.

References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::find_position(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::tree_ptr.

◆ reset_to_node()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_node ( Node *  node)
inlinenoexcept

Put the current node to a specific node.

Its position is computed when it is needed, as Iterator(tree, node) does: marked as the position of an empty tree, has_curr() would be false.

Parameters
[in]nodeto put as current
Precondition
node is a node of the tree, not nullptr.

Definition at line 1134 of file tpl_treapRk.H.

References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Not_Updated.

◆ reset_to_pos()

template<template< class > class NodeType, class Key , class Compare >
void Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_to_pos ( const size_t  pos)
inlinenoexcept

Put the iterator on the inorder position pos.

Parameters
[in]posinorder position; at size() or past it, the iterator is at the end, without current node, even if an int cannot hold it.

Definition at line 1146 of file tpl_treapRk.H.

References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr, Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::curr_pos, and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::saturated_pos().

◆ saturated_pos()

template<template< class > class NodeType, class Key , class Compare >
static int Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::saturated_pos ( const size_t  pos)
inlinestaticprivatenoexcept

◆ update_curr()

◆ update_pos()

◆ verify() [1/2]

template<template< class > class NodeType, class Key , class Compare >
bool Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::verify ( const Iterator &  it) const
inlinenoexcept

◆ verify() [2/2]

template<template< class > class NodeType, class Key , class Compare >
bool Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::verify ( Gen_Treap_Rk *  r) const
inlinenoexcept

Member Data Documentation

◆ curr

◆ curr_pos

◆ Pos_Empty_Container

template<template< class > class NodeType, class Key , class Compare >
constexpr int Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Empty_Container = -2
staticconstexprprotected

◆ Pos_Not_Current

template<template< class > class NodeType, class Key , class Compare >
constexpr int Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Not_Current = -1
staticconstexprprotected

Definition at line 955 of file tpl_treapRk.H.

◆ Pos_Not_Updated

template<template< class > class NodeType, class Key , class Compare >
constexpr int Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Not_Updated = -3
staticconstexprprotected

◆ Pos_Out_Of_Range

template<template< class > class NodeType, class Key , class Compare >
constexpr int Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::Pos_Out_Of_Range = std::numeric_limits<int>::min()
staticconstexprprotected

◆ tree_ptr


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