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

Inorder iterator on the nodes of a binary tree. More...

#include <tpl_binNodeUtils.H>

Inheritance diagram for Aleph::BinNodeInfixIterator< Node >:
[legend]
Collaboration diagram for Aleph::BinNodeInfixIterator< Node >:
[legend]

Public Member Functions

bool is_in_first () const noexcept
 Return true if the iterator is on the first node.
 
bool is_last () const noexcept
 
void swap (BinNodeInfixIterator &it) noexcept
 
 BinNodeInfixIterator ()=default
 
 BinNodeInfixIterator (Node *r)
 Initialize an iterator on the first node inorder.
 
 BinNodeInfixIterator (const BinNodeInfixIterator &it)
 
 BinNodeInfixIterator (BinNodeInfixIterator &&it) noexcept
 
void reset_first ()
 Reset the iterator to the first node inorder; it may throw bad_alloc, as the constructor does.
 
void reset_last () noexcept
 Reset the iterator to the last node inorder.
 
void end () noexcept
 
BinNodeInfixIterator & operator= (const BinNodeInfixIterator &it)
 
BinNodeInfixIterator & operator= (BinNodeInfixIterator &&it) noexcept
 
bool has_curr () const noexcept
 Return true the iterator has current node.
 
Node * get_curr_ne () const noexcept
 Return the current link guaranteeing no exception. Be careful.
 
Node * get_curr () const
 Return the current node. Throw overflow_error if there is no current.
 
size_t get_pos () const
 Return the current position of iterator. Only valid if has_curr() == true.
 
void next_ne ()
 Move forward without checking the position; it may throw bad_alloc, as the constructor does.
 
void next ()
 Move the iterator one position forward.
 

Private Member Functions

Node * advance_to_min (Node *r)
 
void init ()
 

Static Private Member Functions

static Node * advance_to_max (Node *r) noexcept
 

Private Attributes

Node * root = Node::NullPtr
 
Node * curr = Node::NullPtr
 
long pos = 0
 
SmallVector< Node *, Inline_Depth > s
 

Static Private Attributes

static constexpr size_t Inline_Depth = Node::MaxHeight < 128 ? Node::MaxHeight : 128
 

Detailed Description

template<class Node>
class Aleph::BinNodeInfixIterator< Node >

Inorder iterator on the nodes of a binary tree.

This class export a full iterator for the nodes of a binary tree where the visit order corresponds to a inorder sense.

Definition at line 2977 of file tpl_binNodeUtils.H.

Constructor & Destructor Documentation

◆ BinNodeInfixIterator() [1/4]

◆ BinNodeInfixIterator() [2/4]

template<class Node >
Aleph::BinNodeInfixIterator< Node >::BinNodeInfixIterator ( Node *  r)
inline

Initialize an iterator on the first node inorder.

Exceptions
bad_allocif the tree is deeper than the inline capacity of the iterator (Node::MaxHeight, at most 128) and the pending nodes cannot be moved to the heap.

Definition at line 3044 of file tpl_binNodeUtils.H.

References Aleph::BinNodeInfixIterator< Node >::init().

◆ BinNodeInfixIterator() [3/4]

Definition at line 3049 of file tpl_binNodeUtils.H.

◆ BinNodeInfixIterator() [4/4]

template<class Node >
Aleph::BinNodeInfixIterator< Node >::BinNodeInfixIterator ( BinNodeInfixIterator< Node > &&  it)
inlinenoexcept

Definition at line 3055 of file tpl_binNodeUtils.H.

References Aleph::BinNodeInfixIterator< Node >::swap().

Member Function Documentation

◆ advance_to_max()

template<class Node >
static Node * Aleph::BinNodeInfixIterator< Node >::advance_to_max ( Node *  r)
inlinestaticprivatenoexcept

Definition at line 3002 of file tpl_binNodeUtils.H.

References r, and RLINK.

Referenced by Aleph::BinNodeInfixIterator< Node >::reset_last().

◆ advance_to_min()

◆ end()

◆ get_curr()

template<class Node >
Node * Aleph::BinNodeInfixIterator< Node >::get_curr ( ) const
inline

Return the current node. Throw overflow_error if there is no current.

Definition at line 3121 of file tpl_binNodeUtils.H.

References ah_overflow_error_if, Aleph::BinNodeInfixIterator< Node >::curr, and Aleph::BinNodeInfixIterator< Node >::has_curr().

Referenced by Aleph::DynIntervalTree< T, Compare >::Iterator::get_curr().

◆ get_curr_ne()

template<class Node >
Node * Aleph::BinNodeInfixIterator< Node >::get_curr_ne ( ) const
inlinenoexcept

Return the current link guaranteeing no exception. Be careful.

Definition at line 3115 of file tpl_binNodeUtils.H.

References Aleph::BinNodeInfixIterator< Node >::curr.

Referenced by Aleph::DynIntervalTree< T, Compare >::Iterator::get_curr_ne(), and TEST().

◆ get_pos()

template<class Node >
size_t Aleph::BinNodeInfixIterator< Node >::get_pos ( ) const
inline

Return the current position of iterator. Only valid if has_curr() == true.

Definition at line 3128 of file tpl_binNodeUtils.H.

References Aleph::BinNodeInfixIterator< Node >::pos, Aleph::BinNodeInfixIterator< Node >::root, and Aleph::size().

Referenced by Aleph::DynIntervalTree< T, Compare >::Iterator::get_pos().

◆ has_curr()

◆ init()

◆ is_in_first()

template<class Node >
bool Aleph::BinNodeInfixIterator< Node >::is_in_first ( ) const
inlinenoexcept

Return true if the iterator is on the first node.

Definition at line 3019 of file tpl_binNodeUtils.H.

References Aleph::and, Aleph::BinNodeInfixIterator< Node >::curr, Aleph::SmallVector< T, N >::is_empty(), LLINK, and Aleph::BinNodeInfixIterator< Node >::s.

◆ is_last()

◆ next()

template<class Node >
void Aleph::BinNodeInfixIterator< Node >::next ( )
inline

Move the iterator one position forward.

Throw overflow_error if there is no current

Definition at line 3158 of file tpl_binNodeUtils.H.

References ah_overflow_error_if, Aleph::BinNodeInfixIterator< Node >::has_curr(), and Aleph::BinNodeInfixIterator< Node >::next_ne().

Referenced by Aleph::DynIntervalTree< T, Compare >::Iterator::next().

◆ next_ne()

◆ operator=() [1/2]

template<class Node >
BinNodeInfixIterator & Aleph::BinNodeInfixIterator< Node >::operator= ( BinNodeInfixIterator< Node > &&  it)
inlinenoexcept

Definition at line 3102 of file tpl_binNodeUtils.H.

References Aleph::BinNodeInfixIterator< Node >::swap().

◆ operator=() [2/2]

◆ reset_first()

template<class Node >
void Aleph::BinNodeInfixIterator< Node >::reset_first ( )
inline

Reset the iterator to the first node inorder; it may throw bad_alloc, as the constructor does.

Definition at line 3062 of file tpl_binNodeUtils.H.

References Aleph::SmallVector< T, N >::empty(), Aleph::BinNodeInfixIterator< Node >::init(), and Aleph::BinNodeInfixIterator< Node >::s.

Referenced by Aleph::DynIntervalTree< T, Compare >::Iterator::reset_first().

◆ reset_last()

◆ swap()

Member Data Documentation

◆ curr

◆ Inline_Depth

template<class Node >
constexpr size_t Aleph::BinNodeInfixIterator< Node >::Inline_Depth = Node::MaxHeight < 128 ? Node::MaxHeight : 128
staticconstexprprivate

Definition at line 2989 of file tpl_binNodeUtils.H.

◆ pos

◆ root

◆ s


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