30 #ifndef GUM_BIN_SEARCH_TREE_H 31 #define GUM_BIN_SEARCH_TREE_H 39 #ifndef DOXYGEN_SHOULD_SKIP_THIS 41 template <
typename Val,
class Cmp,
class Node >
44 template <
typename Val,
class Cmp,
class Node >
45 class BinSearchTreeIterator;
46 #endif // DOXYGEN_SHOULD_SKIP_THIS 64 template <
typename Val,
65 class Cmp = std::less< Val >,
66 class Node = BinTreeNode< Val > >
127 const_iterator
begin()
const;
137 const_iterator
rbegin()
const;
144 const iterator&
end();
146 const const_iterator&
end()
const;
154 const iterator&
rend();
156 const const_iterator&
rend()
const;
165 const_iterator
root()
const;
212 const Val&
insert(
const Val& val);
219 void erase(
const Val& val);
229 void erase(
const iterator& iter);
236 bool contains(
const Val& val)
const;
260 virtual const std::string
toString()
const;
336 Node*
_copy(Node* root_from,
376 Node*
_getNode(
const Val& val)
const;
394 virtual void _erase(Node* node);
422 virtual Node*
_insert(
const Val& val);
447 template <
typename Val,
class Cmp,
class Node >
631 const Node* current_node,
632 bool add_to_iterator_list);
638 void _detachFromTree();
644 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 652 #endif // GUM_BIN_SEARCH_TREE_H iterator _iter_end
Pseudo static iterator.
virtual ~BinSearchTree()
Class destructor.
BinSearchTree< Val, Cmp, Node > * _tree
The binary search tree pointed to by the iterator.
A generic binary search tree.
Node * _getNode(const Val &val) const
Returns the node containing a given value.
Node * _maxNode(Node *node) const
Returns the greatest node w.r.t.
Cmp _cmp
The comparison function.
Size size() const
Returns the number of elements in the binary search tree.
Node * _left_child
The left child to be used when _node=0 and leftdown() is applied.
Node * _next_node
The next node to be used when _node=0 (if a ++ operator is applied).
const Val & insert(const Val &val)
Creates a copy of the value, insert it in the tree and returns the copy value.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
iterator rbegin()
Reverse iterator.
Node * _copy(Node *root_from, Node *parent=0, BinTreeDir dir=BinTreeDir::LEFT_CHILD)
A method for recursively copying the contents of a BinSearchTree.
void _deleteSubTree(Node *node)
A method for recursively deleting a subtree of the gum::BinSearchTree.
bool _uniqueness_policy
The uniqueness property: whether the same value can appear multiple times.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
BinSearchTreeIterator< Val, Cmp, Node > const_iterator
Alias for gum::BinSearchTree iterators.
BinTreeDir
The direction of a given edge in a binary tree.
bool empty() const
Indicates whether the gum::BinSearchTree search tree is empty.
iterator root()
Returns an iterator at the root of the tree.
const Val & minValue() const
Returns the value of the leftmost node with the minimal key in the tree.
const Val & rootValue() const
Returns the value of the root of the tree.
Node * _parent
The parent to be used when _node=0 (if operation up is applied).
const Val & maxValue() const
Returns the value of the rightmost node with the maximal key in the tree.
Node * _right_child
The right child to be used when _node=0 and rightdown() is applied.
Formula operator*(const Formula &a, const Formula &b)
BinSearchTree(bool uniqueness_policy=false)
Basic constructor: returns an empty binary search tree.
bool operator==(const TiXmlString &a, const TiXmlString &b)
Node * _node
The current node pointed to by the iterator.
bool uniquenessPolicy() const
Returns the current uniqueness policy.
A Generic binary search tree.
iterator * _iterator_list
The list of iterators pointing to the binary search tree.
virtual Node * _insert(const Val &val)
Creates a copy of the value, insert it in the gum::BinSearchTree and returns the copy value...
BinSearchTreeIterator< Val, Cmp, Node > iterator
Alias for gum::BinSearchTree iterators.
void __updateEraseIterators(Node *node)
Update all iterators when a given node is deleted.
void clear()
Removes all the elements from the gum::BinSearchTree.
virtual const std::string toString() const
Displays the content of the tree, in increasing order w.r.t.
const iterator & rend()
Reverse end iterator.
void erase(const Val &val)
Erase the leftmost node with the given (key,val) pair.
Size _nb_elements
The number of elements stored in the tree.
void setUniquenessPolicy(const bool new_policy)
Enables the user to change dynamically the policy for checking whether there can exist several identi...
bool operator!=(const TiXmlString &a, const TiXmlString &b)
Node * _prev_node
The preceding node to be used when _node=0 (if a – operator is applied).
const iterator & end()
End iterator.
BinSearchTree< Val, Cmp, Node > & operator=(const BinSearchTree< Val, Cmp, Node > &from)
Copy operator.
BinSearchTreeIterator< Val, Cmp, Node > * _next_iter
The next iterator in the list of iterators of the binSearchTree.
Node * _succNode(Node *node) const
Returns the next node according to the weak ordering Cmp.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
bool contains(const Val &val) const
Returns true if the gum::BinSearchTree contains the value.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void _erase(Node *node)
Erase the node passed in argument.
iterator begin()
Begin iterator.
Node * _minNode(Node *node) const
Returns the smallest node w.r.t.
Node * _root
The root node of the tree.
void __eraseWithTwoChildren(Node *node)
Erase a node with two children.
Node * _prevNode(Node *node) const
Returns the previous node according to weak ordering Cmp.