![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
A Generic binary search tree. More...
#include <agrum/tools/core/binSearchTree.h>
Public Member Functions | |
BinSearchTreeIterator () | |
Class Constructors and Destructors. More... | |
BinSearchTreeIterator (const BinSearchTreeIterator< Val, Cmp, Node > &from) | |
Copy constructor: creates an iterator pointing toward the same tree. More... | |
~BinSearchTreeIterator () | |
Class destructor. More... | |
BinSearchTreeIterator< Val, Cmp, Node > & | operator= (const BinSearchTreeIterator< Val, Cmp, Node > &from) |
Class operators. More... | |
const Val & | operator* () const |
Returns the value pointed to by the iterator. More... | |
BinSearchTreeIterator< Val, Cmp, Node > & | operator++ () |
Point the iterator to the next value in the binary search tree. More... | |
BinSearchTreeIterator< Val, Cmp, Node > & | operator-- () |
Point the iterator to the preceding value in the binary search tree. More... | |
bool | operator!= (const BinSearchTreeIterator< Val, Cmp, Node > &from) const |
Checks whether two iterators are pointing toward different elements. More... | |
bool | operator== (const BinSearchTreeIterator< Val, Cmp, Node > &from) const |
Checks whether two iterators are pointing toward identical elements. More... | |
Accessors / Modifiers | |
BinSearchTreeIterator< Val, Cmp, Node > & | up () |
Makes the iterator move to its parent node. More... | |
BinSearchTreeIterator< Val, Cmp, Node > & | downLeft () |
Makes the iterator move to the left child of the node it points to. More... | |
BinSearchTreeIterator< Val, Cmp, Node > & | downRight () |
Makes the iterator move to the right child of the node it points to. More... | |
void | clear () |
Detach the iterator from its current tree (if any) and reset it. More... | |
Protected Attributes | |
Node * | node_ |
The current node pointed to by the iterator. More... | |
Node * | next_node_ |
The next node to be used when node_=0 (if a ++ operator is applied). More... | |
Node * | prev_node_ |
The preceding node to be used when node_=0 (if a – operator is applied). More... | |
Node * | parent_ |
The parent to be used when node_=0 (if operation up is applied). More... | |
Node * | left_child_ |
The left child to be used when node_=0 and leftdown() is applied. More... | |
Node * | right_child_ |
The right child to be used when node_=0 and rightdown() is applied. More... | |
BinSearchTree< Val, Cmp, Node > * | tree_ |
The binary search tree pointed to by the iterator. More... | |
BinSearchTreeIterator< Val, Cmp, Node > * | next_iter_ |
The next iterator in the list of iterators of the binSearchTree. More... | |
Friends | |
class | BinSearchTree< Val, Cmp, Node > |
To speed-up accesses. More... | |
A Generic binary search tree.
Val | The values type to store in the binary search tree. |
Cmp | The compatator for sorting the binary search tree. |
Node | The nodes type used to store values in the binary search tree. |
Definition at line 442 of file binSearchTree.h.
gum::BinSearchTreeIterator< Val, Cmp, Node >::BinSearchTreeIterator | ( | ) |
Class Constructors and Destructors.
Basic constructor: returns an iterator pointing toward nothing.
gum::BinSearchTreeIterator< Val, Cmp, Node >::BinSearchTreeIterator | ( | const BinSearchTreeIterator< Val, Cmp, Node > & | from | ) |
Copy constructor: creates an iterator pointing toward the same tree.
from | The gum::BinSearchTreeIterator to copy. |
gum::BinSearchTreeIterator< Val, Cmp, Node >::~BinSearchTreeIterator | ( | ) |
Class destructor.
void gum::BinSearchTreeIterator< Val, Cmp, Node >::clear | ( | ) |
Detach the iterator from its current tree (if any) and reset it.
|
private |
a method to detach the current iterator from its tree's iterator's list.
BinSearchTreeIterator< Val, Cmp, Node >& gum::BinSearchTreeIterator< Val, Cmp, Node >::downLeft | ( | ) |
Makes the iterator move to the left child of the node it points to.
BinSearchTreeIterator< Val, Cmp, Node >& gum::BinSearchTreeIterator< Val, Cmp, Node >::downRight | ( | ) |
Makes the iterator move to the right child of the node it points to.
|
private |
A function called to initialize an iterator.
Assuming that the iterator has been constructed using the default constructor (i.e., it points toward no binary search tree), this method make it point toward one tree and, if needed, add it to the set of iterators of the tree.
tree | The gum::BinSearchTree to iterate on. |
current_node | The node pointed by this iterator. |
add_to_iterator_list | Add this iterator to the iterator list. |
bool gum::BinSearchTreeIterator< Val, Cmp, Node >::operator!= | ( | const BinSearchTreeIterator< Val, Cmp, Node > & | from | ) | const |
Checks whether two iterators are pointing toward different elements.
from | The gum::BinSearchTreeIterator to test for inequality. |
const Val& gum::BinSearchTreeIterator< Val, Cmp, Node >::operator* | ( | ) | const |
Returns the value pointed to by the iterator.
UndefinedIteratorValue | Raised if the iterator does not point to a valid node of the tree. |
BinSearchTreeIterator< Val, Cmp, Node >& gum::BinSearchTreeIterator< Val, Cmp, Node >::operator++ | ( | ) |
Point the iterator to the next value in the binary search tree.
A binary search tree stores data according to a complete weak order <=. A ++ operation on an iterator makes the latter point on the next value in the tree w.r.t. ordering <=.
Loops are guaranteed to parse the whole binary search tree as long as no element is added to or deleted from the tree while being in the loop. Deleting elements during the loop is guaranteed to never produce a segmentation fault.
BinSearchTreeIterator< Val, Cmp, Node >& gum::BinSearchTreeIterator< Val, Cmp, Node >::operator-- | ( | ) |
Point the iterator to the preceding value in the binary search tree.
A binary search tree stores data according to a complete weak order <=. A – operation on an iterator makes the latter point on the preceding value in the tree w.r.t. ordering <=.
Loops are guaranteed to parse the whole binary search tree as long as no element is added to or deleted from the tree while being in the loop. Deleting elements during the loop is guaranteed to never produce a segmentation fault.
BinSearchTreeIterator< Val, Cmp, Node >& gum::BinSearchTreeIterator< Val, Cmp, Node >::operator= | ( | const BinSearchTreeIterator< Val, Cmp, Node > & | from | ) |
Class operators.
Copy operator.
from | the gum::BinSearchTreeIterator to copy. |
bool gum::BinSearchTreeIterator< Val, Cmp, Node >::operator== | ( | const BinSearchTreeIterator< Val, Cmp, Node > & | from | ) | const |
Checks whether two iterators are pointing toward identical elements.
from | The gum::BinSearchTreeIterator to test for equality. |
BinSearchTreeIterator< Val, Cmp, Node >& gum::BinSearchTreeIterator< Val, Cmp, Node >::up | ( | ) |
Makes the iterator move to its parent node.
|
friend |
To speed-up accesses.
Definition at line 609 of file binSearchTree.h.
|
protected |
The left child to be used when node_=0 and leftdown() is applied.
Definition at line 595 of file binSearchTree.h.
|
protected |
The next iterator in the list of iterators of the binSearchTree.
Definition at line 604 of file binSearchTree.h.
|
protected |
The next node to be used when node_=0 (if a ++ operator is applied).
Definition at line 585 of file binSearchTree.h.
|
protected |
The current node pointed to by the iterator.
Definition at line 582 of file binSearchTree.h.
|
protected |
The parent to be used when node_=0 (if operation up is applied).
Definition at line 592 of file binSearchTree.h.
|
protected |
The preceding node to be used when node_=0 (if a – operator is applied).
Definition at line 589 of file binSearchTree.h.
|
protected |
The right child to be used when node_=0 and rightdown() is applied.
Definition at line 598 of file binSearchTree.h.
|
protected |
The binary search tree pointed to by the iterator.
Definition at line 601 of file binSearchTree.h.