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

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

#include <tpl_binNodeUtils.H>

Collaboration diagram for Aleph::BinNodePrefixIterator< Node >:
[legend]

Public Member Functions

void swap (BinNodePrefixIterator &it) noexcept
 Swap thiswith it
 
 BinNodePrefixIterator ()=default
 
 BinNodePrefixIterator (Node *r) noexcept
 Initialize an iterator on the first node in preorder for the tree with root r
 
 BinNodePrefixIterator (const BinNodePrefixIterator &it)
 
 BinNodePrefixIterator (BinNodePrefixIterator &&it) noexcept
 
void reset_first () noexcept
 Reset the iterator to the first node in preorder sense.
 
void reset_last () noexcept
 Reset the iterator to the last node in preorder.
 
void end () noexcept
 Put the iterator in end state.
 
BinNodePrefixIterator & operator= (const BinNodePrefixIterator &it)
 
BinNodePrefixIterator & operator= (BinNodePrefixIterator &&it) noexcept
 
bool has_curr () const noexcept
 Return true if iterator has current node.
 
Node * get_curr_ne () const noexcept
 Return the current link guaranteeing no exception. Be careful.
 
Node * get_curr () const
 Return a pointer to current node.
 
void next_ne ()
 Move the iterator one position forward without checking it.
 
void next ()
 Move the iterator one position forward.
 

Static Private Member Functions

static Node * last (Node *p) noexcept
 

Private Attributes

Node * root = nullptr
 
Node * curr = Node::NullPtr
 
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::BinNodePrefixIterator< Node >

Preorder 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 preorder sense.

Definition at line 2758 of file tpl_binNodeUtils.H.

Constructor & Destructor Documentation

◆ BinNodePrefixIterator() [1/4]

◆ BinNodePrefixIterator() [2/4]

template<class Node >
Aleph::BinNodePrefixIterator< Node >::BinNodePrefixIterator ( Node *  r)
inlinenoexcept

Initialize an iterator on the first node in preorder for the tree with root r

Definition at line 2784 of file tpl_binNodeUtils.H.

◆ BinNodePrefixIterator() [3/4]

Definition at line 2789 of file tpl_binNodeUtils.H.

◆ BinNodePrefixIterator() [4/4]

Member Function Documentation

◆ end()

template<class Node >
void Aleph::BinNodePrefixIterator< Node >::end ( )
inlinenoexcept

◆ get_curr()

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

◆ get_curr_ne()

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

Return the current link guaranteeing no exception. Be careful.

Definition at line 2864 of file tpl_binNodeUtils.H.

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

Referenced by Aleph::BinNodePrefixIterator< Node >::get_curr().

◆ has_curr()

template<class Node >
bool Aleph::BinNodePrefixIterator< Node >::has_curr ( ) const
inlinenoexcept

◆ last()

template<class Node >
static Node * Aleph::BinNodePrefixIterator< Node >::last ( Node *  p)
inlinestaticprivatenoexcept

◆ next()

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

Move the iterator one position forward.

Definition at line 2905 of file tpl_binNodeUtils.H.

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

◆ next_ne()

template<class Node >
void Aleph::BinNodePrefixIterator< Node >::next_ne ( )
inline

Move the iterator one position forward without checking it.

Be careful.

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 2881 of file tpl_binNodeUtils.H.

References Aleph::SmallVector< T, N >::append(), Aleph::BinNodePrefixIterator< Node >::curr, Aleph::SmallVector< T, N >::is_empty(), l, LLINK, r, Aleph::SmallVector< T, N >::remove_last(), RLINK, and Aleph::BinNodePrefixIterator< Node >::s.

Referenced by Aleph::BinNodePrefixIterator< Node >::next().

◆ operator=() [1/2]

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

Definition at line 2851 of file tpl_binNodeUtils.H.

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

◆ operator=() [2/2]

◆ reset_first()

template<class Node >
void Aleph::BinNodePrefixIterator< Node >::reset_first ( )
inlinenoexcept

◆ reset_last()

◆ swap()

Member Data Documentation

◆ curr

◆ Inline_Depth

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

Definition at line 2768 of file tpl_binNodeUtils.H.

◆ root

◆ s


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