aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::AVLTreeIterator< Val, Cmp > Class Template Reference

AVL binary search tree iterator. More...

#include <agrum/base/core/AVLTree.h>

Collaboration diagram for gum::AVLTreeIterator< Val, Cmp >:

Public Types

using iterator_category = std::bidirectional_iterator_tag
 Types for STL compliance.
using value_type = Val
 Types for STL compliance.
using reference = value_type&
 Types for STL compliance.
using const_reference = const value_type&
 Types for STL compliance.
using pointer = value_type*
 Types for STL compliance.
using const_pointer = const value_type*
 Types for STL compliance.

Public Member Functions

Constructors / Destructors
 AVLTreeIterator (const AVLTree< Val, Cmp > &tree, const bool begin=true) noexcept
 constructor for begin iterators
 AVLTreeIterator (const AVLTreeIterator< Val, Cmp > &from) noexcept
 copy constructor
 AVLTreeIterator (AVLTreeIterator< Val, Cmp > &&from) noexcept
 move constructor
 ~AVLTreeIterator () noexcept
 destructor
Operators
AVLTreeIterator< Val, Cmp > & operator= (const AVLTreeIterator< Val, Cmp > &from) noexcept
 copy operator
AVLTreeIterator< Val, Cmp > & operator= (AVLTreeIterator< Val, Cmp > &&from) noexcept
 move operator
bool operator== (const AVLTreeIterator< Val, Cmp > &from) const
 indicates whether two iterator point to the same element
bool operator!= (const AVLTreeIterator< Val, Cmp > &from) const
 indicates whether two iterator point to different element
AVLTreeIterator< Val, Cmp > & operator++ () noexcept
 move to the next element in the tree
AVLTreeIterator< Val, Cmp > & operator+= (const Size k) noexcept
 move to the next k element
AVLTreeIterator< Val, Cmp > & operator-- () noexcept
 move to the preceding element in the tree
AVLTreeIterator< Val, Cmp > & operator-= (const Size k) noexcept
 move to the preceding k element
const_reference operator* () const
 returns the element pointed to by the iterator

Protected Types

using AVLNode = AVLTreeNode< Val >
 the type of the nodes of the tree

Protected Member Functions

AVLNodenextNode_ (AVLNode *node) const noexcept
 computes the node to go to when applying operator++
AVLNodeprecedingNode_ (AVLNode *node) const noexcept
 computes the node to go to when applying operator--
void unregisterTree_ () noexcept
 make the iterator point to nothing
void pointToEndRend_ () noexcept
 force the iterator to point to end/rend

Protected Attributes

AVLTree< Val, Cmp > * tree_ {nullptr}
 the tree the iterator points to
AVLNodenode_ {nullptr}
 the AVLNode the iterator points to
AVLNodenext_node_ {nullptr}
 the next node to go to when applying operator++
AVLNodepreceding_node_ {nullptr}
 the preceding node to go to when applying operator--
friend AVLTree< Val, Cmp >
 allow AVL trees to access the content of the iterators

Detailed Description

template<typename Val, typename Cmp = std::less< Val >>
class gum::AVLTreeIterator< Val, Cmp >

AVL binary search tree iterator.

Template Parameters
ValThe type of the elements stored into the tree.
CmpThe function used for sorting the elements. queues.

Definition at line 457 of file AVLTree.h.

Member Typedef Documentation

◆ AVLNode

template<typename Val, typename Cmp = std::less< Val >>
using gum::AVLTreeIterator< Val, Cmp >::AVLNode = AVLTreeNode< Val >
protected

the type of the nodes of the tree

Definition at line 551 of file AVLTree.h.

◆ const_pointer

template<typename Val, typename Cmp = std::less< Val >>
using gum::AVLTreeIterator< Val, Cmp >::const_pointer = const value_type*

Types for STL compliance.

Definition at line 466 of file AVLTree.h.

◆ const_reference

template<typename Val, typename Cmp = std::less< Val >>
using gum::AVLTreeIterator< Val, Cmp >::const_reference = const value_type&

Types for STL compliance.

Definition at line 464 of file AVLTree.h.

◆ iterator_category

template<typename Val, typename Cmp = std::less< Val >>
using gum::AVLTreeIterator< Val, Cmp >::iterator_category = std::bidirectional_iterator_tag

Types for STL compliance.

Definition at line 461 of file AVLTree.h.

◆ pointer

template<typename Val, typename Cmp = std::less< Val >>
using gum::AVLTreeIterator< Val, Cmp >::pointer = value_type*

Types for STL compliance.

Definition at line 465 of file AVLTree.h.

◆ reference

template<typename Val, typename Cmp = std::less< Val >>
using gum::AVLTreeIterator< Val, Cmp >::reference = value_type&

Types for STL compliance.

Definition at line 463 of file AVLTree.h.

◆ value_type

template<typename Val, typename Cmp = std::less< Val >>
using gum::AVLTreeIterator< Val, Cmp >::value_type = Val

Types for STL compliance.

Definition at line 462 of file AVLTree.h.

Constructor & Destructor Documentation

◆ AVLTreeIterator() [1/3]

template<typename Val, typename Cmp = std::less< Val >>
gum::AVLTreeIterator< Val, Cmp >::AVLTreeIterator ( const AVLTree< Val, Cmp > & tree,
const bool begin = true )
explicitnoexcept

constructor for begin iterators

Parameters
treethe AVL tree which parses the iterator
beginif true, the iterator points to the lowest value in the tree, else it points to the highest value

◆ AVLTreeIterator() [2/3]

template<typename Val, typename Cmp = std::less< Val >>
gum::AVLTreeIterator< Val, Cmp >::AVLTreeIterator ( const AVLTreeIterator< Val, Cmp > & from)
noexcept

copy constructor

◆ AVLTreeIterator() [3/3]

template<typename Val, typename Cmp = std::less< Val >>
gum::AVLTreeIterator< Val, Cmp >::AVLTreeIterator ( AVLTreeIterator< Val, Cmp > && from)
noexcept

move constructor

◆ ~AVLTreeIterator()

template<typename Val, typename Cmp = std::less< Val >>
gum::AVLTreeIterator< Val, Cmp >::~AVLTreeIterator ( )
noexcept

destructor

Member Function Documentation

◆ nextNode_()

template<typename Val, typename Cmp = std::less< Val >>
AVLNode * gum::AVLTreeIterator< Val, Cmp >::nextNode_ ( AVLNode * node) const
protectednoexcept

computes the node to go to when applying operator++

◆ operator!=()

template<typename Val, typename Cmp = std::less< Val >>
bool gum::AVLTreeIterator< Val, Cmp >::operator!= ( const AVLTreeIterator< Val, Cmp > & from) const

indicates whether two iterator point to different element

◆ operator*()

template<typename Val, typename Cmp = std::less< Val >>
const_reference gum::AVLTreeIterator< Val, Cmp >::operator* ( ) const

returns the element pointed to by the iterator

Returns
the element pointed to by the iterator, if the iterator actually points to an element
Exceptions
NotFoundis raised if the iterator does not point to any element

◆ operator++()

template<typename Val, typename Cmp = std::less< Val >>
AVLTreeIterator< Val, Cmp > & gum::AVLTreeIterator< Val, Cmp >::operator++ ( )
noexcept

move to the next element in the tree

Warning
Applying this operator to an iterator equal to the end iterator has no effect. In particular, it does not raise any exception.

◆ operator+=()

template<typename Val, typename Cmp = std::less< Val >>
AVLTreeIterator< Val, Cmp > & gum::AVLTreeIterator< Val, Cmp >::operator+= ( const Size k)
noexcept

move to the next k element

Warning
Applying this operator to an iterator equal to the end iterator has no effect. In particular, it does not raise any exception.

◆ operator--()

template<typename Val, typename Cmp = std::less< Val >>
AVLTreeIterator< Val, Cmp > & gum::AVLTreeIterator< Val, Cmp >::operator-- ( )
noexcept

move to the preceding element in the tree

Warning
Applying this operator to an iterator equal to the begin iterator has no effect. In particular, it does not raise any exception.

◆ operator-=()

template<typename Val, typename Cmp = std::less< Val >>
AVLTreeIterator< Val, Cmp > & gum::AVLTreeIterator< Val, Cmp >::operator-= ( const Size k)
noexcept

move to the preceding k element

Warning
Applying this operator to an iterator equal to the begin iterator has no effect. In particular, it does not raise any exception.

◆ operator=() [1/2]

template<typename Val, typename Cmp = std::less< Val >>
AVLTreeIterator< Val, Cmp > & gum::AVLTreeIterator< Val, Cmp >::operator= ( AVLTreeIterator< Val, Cmp > && from)
noexcept

move operator

◆ operator=() [2/2]

template<typename Val, typename Cmp = std::less< Val >>
AVLTreeIterator< Val, Cmp > & gum::AVLTreeIterator< Val, Cmp >::operator= ( const AVLTreeIterator< Val, Cmp > & from)
noexcept

copy operator

◆ operator==()

template<typename Val, typename Cmp = std::less< Val >>
bool gum::AVLTreeIterator< Val, Cmp >::operator== ( const AVLTreeIterator< Val, Cmp > & from) const

indicates whether two iterator point to the same element

◆ pointToEndRend_()

template<typename Val, typename Cmp = std::less< Val >>
void gum::AVLTreeIterator< Val, Cmp >::pointToEndRend_ ( )
protectednoexcept

force the iterator to point to end/rend

◆ precedingNode_()

template<typename Val, typename Cmp = std::less< Val >>
AVLNode * gum::AVLTreeIterator< Val, Cmp >::precedingNode_ ( AVLNode * node) const
protectednoexcept

computes the node to go to when applying operator--

◆ unregisterTree_()

template<typename Val, typename Cmp = std::less< Val >>
void gum::AVLTreeIterator< Val, Cmp >::unregisterTree_ ( )
protectednoexcept

make the iterator point to nothing

Member Data Documentation

◆ AVLTree< Val, Cmp >

template<typename Val, typename Cmp = std::less< Val >>
friend gum::AVLTreeIterator< Val, Cmp >::AVLTree< Val, Cmp >
protected

allow AVL trees to access the content of the iterators

Definition at line 580 of file AVLTree.h.

◆ next_node_

template<typename Val, typename Cmp = std::less< Val >>
AVLNode* gum::AVLTreeIterator< Val, Cmp >::next_node_ {nullptr}
protected

the next node to go to when applying operator++

Definition at line 560 of file AVLTree.h.

560{nullptr};

◆ node_

template<typename Val, typename Cmp = std::less< Val >>
AVLNode* gum::AVLTreeIterator< Val, Cmp >::node_ {nullptr}
protected

the AVLNode the iterator points to

Definition at line 557 of file AVLTree.h.

557{nullptr};

◆ preceding_node_

template<typename Val, typename Cmp = std::less< Val >>
AVLNode* gum::AVLTreeIterator< Val, Cmp >::preceding_node_ {nullptr}
protected

the preceding node to go to when applying operator--

Definition at line 563 of file AVLTree.h.

563{nullptr};

◆ tree_

template<typename Val, typename Cmp = std::less< Val >>
AVLTree< Val, Cmp >* gum::AVLTreeIterator< Val, Cmp >::tree_ {nullptr}
protected

the tree the iterator points to

Definition at line 554 of file AVLTree.h.

554{nullptr};

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