![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
A splay tree. More...
#include <agrum/base/core/splay.h>
Public Member Functions | |
Constructors / Destructors | |
| SplayTree () | |
| Basic constructor, make an empty splay tree. | |
| SplayTree (const Element &e) | |
| Basic constructor, make a splay tree with one element. | |
| SplayTree (const SplayTree &from) | |
| Copy constructor. | |
| ~SplayTree () | |
| Class destructor. | |
Operators | |
| SplayTree< Element > & | operator= (const SplayTree< Element > &from) |
| Assignment operator. | |
Methods | |
| Element & | operator[] (const unsigned int i) |
| Get the element at the position n. | |
| const Element & | operator[] (const unsigned int i) const |
| Get the element at the position n. | |
| Element & | front () |
| Get the first element. | |
| Element & | back () |
| Get the last element. | |
| void | popFront () |
| Remove the first element. | |
| void | popBack () |
| Remove the last element. | |
| void | pushFront (const Element &e) |
| Add an element in the first position. | |
| void | pushBack (const Element &e) |
| Add an element in the last position. | |
| void | insert (const Element &e) |
| Add an element to the tree. | |
| void | join (const SplayTree< Element > &s) |
| Concatenation of two trees. | |
| SplayTree< Element > | split (const int i) |
| Divide the tree at the position. | |
| SplayTree< Element > | split_by_val (const Element &e) |
| Divide the tree at the position. | |
| Size | size () const |
| The number of elements in the tree. | |
| bool | contains (const Element &e) const |
| Test if the tree contains the element. | |
Protected Member Functions | |
| void | copy_ (const SplayTree< Element > &) |
| a function used to perform copies | |
Protected Attributes | |
Data Menbers | |
| SplayBinaryNode< Element > * | root |
| Root of the tree. | |
| HashTable< Element, SplayBinaryNode< Element > * > | addr |
| The hash table to find quickly the position of a node. | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const SplayTree< Element > &s) |
| Friendly to display. | |
A splay tree.
| Element | The elements type. |
| INLINE gum::SplayTree< Element >::SplayTree | ( | ) |
Basic constructor, make an empty splay tree.
Definition at line 376 of file splay_tpl.h.
References SplayTree(), addr, and root.
Referenced by SplayTree(), SplayTree(), SplayTree(), ~SplayTree(), copy_(), join(), operator<<, operator=(), split(), and split_by_val().
| INLINE gum::SplayTree< Element >::SplayTree | ( | const Element & | e | ) |
Basic constructor, make a splay tree with one element.
| e | The element of the tree. |
Definition at line 387 of file splay_tpl.h.
References SplayTree(), addr, and root.
| INLINE gum::SplayTree< Element >::SplayTree | ( | const SplayTree< Element > & | from | ) |
Copy constructor.
| from | The gum::SplayTree to copy. |
Definition at line 396 of file splay_tpl.h.
References SplayTree(), addr, and copy_().
| INLINE gum::SplayTree< Element >::~SplayTree | ( | ) |
Class destructor.
Definition at line 425 of file splay_tpl.h.
References SplayTree(), and root.
| INLINE Element & gum::SplayTree< Element >::back | ( | ) |
Get the last element.
| NotFound | Raised if the splay tree is empty. |
Definition at line 524 of file splay_tpl.h.
References gum::SplayBinaryNode< Element >::fd, GUM_ERROR, root, and gum::SplayBinaryNode< Element >::splay().
| INLINE bool gum::SplayTree< Element >::contains | ( | const Element & | e | ) | const |
Test if the tree contains the element.
| e | The element to test if it is in the splay tree. |
Definition at line 787 of file splay_tpl.h.
References addr.
|
protected |
a function used to perform copies
Definition at line 365 of file splay_tpl.h.
References SplayTree(), addr, and root.
Referenced by SplayTree(), and operator=().
| INLINE Element & gum::SplayTree< Element >::front | ( | ) |
Get the first element.
| NotFound | Raised if the splay tree is empty. |
Definition at line 507 of file splay_tpl.h.
References gum::SplayBinaryNode< Element >::fg, GUM_ERROR, root, and gum::SplayBinaryNode< Element >::splay().
| INLINE void gum::SplayTree< Element >::insert | ( | const Element & | e | ) |
Add an element to the tree.
| e | The element to add. |
Definition at line 625 of file splay_tpl.h.
References addr, gum::SplayBinaryNode< Element >::fd, root, gum::SplayBinaryNode< Element >::size, and gum::SplayBinaryNode< Element >::splay().
| INLINE void gum::SplayTree< Element >::join | ( | const SplayTree< Element > & | s | ) |
Concatenation of two trees.
| s | The tree to add. |
Definition at line 651 of file splay_tpl.h.
References SplayTree(), addr, and root.
| INLINE SplayTree< Element > & gum::SplayTree< Element >::operator= | ( | const SplayTree< Element > & | from | ) |
Assignment operator.
| from | The gum::SplayTree to copy. |
Definition at line 405 of file splay_tpl.h.
References SplayTree(), addr, copy_(), and root.
| Element & gum::SplayTree< Element >::operator[] | ( | const unsigned int | i | ) |
Get the element at the position n.
| i | The position of the element to return. |
| NotFound | Raised if no element was found. |
Definition at line 435 of file splay_tpl.h.
References gum::SplayBinaryNode< Element >::fd, gum::SplayBinaryNode< Element >::fg, GUM_ERROR, root, gum::SplayBinaryNode< Element >::size, and gum::SplayBinaryNode< Element >::splay().
| const Element & gum::SplayTree< Element >::operator[] | ( | const unsigned int | i | ) | const |
Get the element at the position n.
| i | The position of the element to return. |
| NotFound | Raised if no element was found. |
Definition at line 470 of file splay_tpl.h.
References gum::SplayBinaryNode< Element >::fd, gum::SplayBinaryNode< Element >::fg, GUM_ERROR, root, gum::SplayBinaryNode< Element >::size, and gum::SplayBinaryNode< Element >::splay().
| INLINE void gum::SplayTree< Element >::popBack | ( | ) |
Remove the last element.
Definition at line 564 of file splay_tpl.h.
References gum::SplayBinaryNode< Element >::fd, gum::SplayBinaryNode< Element >::fg, root, and gum::SplayBinaryNode< Element >::splay().
| INLINE void gum::SplayTree< Element >::popFront | ( | ) |
Remove the first element.
Definition at line 541 of file splay_tpl.h.
References gum::SplayBinaryNode< Element >::fd, gum::SplayBinaryNode< Element >::fg, root, and gum::SplayBinaryNode< Element >::splay().
| INLINE void gum::SplayTree< Element >::pushBack | ( | const Element & | e | ) |
Add an element in the last position.
| e | The element to push. |
Definition at line 606 of file splay_tpl.h.
References addr, gum::SplayBinaryNode< Element >::fd, root, and gum::SplayBinaryNode< Element >::splay().
| INLINE void gum::SplayTree< Element >::pushFront | ( | const Element & | e | ) |
Add an element in the first position.
| e | The element to push. |
Definition at line 587 of file splay_tpl.h.
References addr, gum::SplayBinaryNode< Element >::fg, root, and gum::SplayBinaryNode< Element >::splay().
| INLINE Size gum::SplayTree< Element >::size | ( | ) | const |
| INLINE SplayTree< Element > gum::SplayTree< Element >::split | ( | const int | i | ) |
Divide the tree at the position.
| i | The position of the element (e) for split. |
Definition at line 677 of file splay_tpl.h.
References SplayTree(), addr, gum::SplayBinaryNode< Element >::fd, gum::SplayBinaryNode< Element >::fg, gum::SplayBinaryNode< Element >::position(), gum::removeInfo(), root, size(), and gum::SplayBinaryNode< Element >::splay().
| INLINE SplayTree< Element > gum::SplayTree< Element >::split_by_val | ( | const Element & | e | ) |
Divide the tree at the position.
| e | the element for split |
Definition at line 741 of file splay_tpl.h.
References SplayTree(), addr, gum::SplayBinaryNode< Element >::fd, gum::SplayBinaryNode< Element >::fg, GUM_ERROR, gum::removeInfo(), root, and gum::SplayBinaryNode< Element >::splay().
|
friend |
|
protected |
The hash table to find quickly the position of a node.
Definition at line 437 of file splay.h.
Referenced by SplayTree(), SplayTree(), SplayTree(), contains(), copy_(), insert(), join(), operator=(), pushBack(), pushFront(), split(), and split_by_val().
|
protected |
Root of the tree.
Definition at line 434 of file splay.h.
Referenced by SplayTree(), SplayTree(), ~SplayTree(), back(), copy_(), front(), insert(), join(), operator<<, operator=(), operator[](), operator[](), popBack(), popFront(), pushBack(), pushFront(), size(), split(), and split_by_val().