Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/avl/GenTree.h>
Classes | |
class | Iter |
class | Node |
class | Stack |
class | VisitStack |
Public Types | |
typedef T | t |
typedef GenTree< T, K, C, A > | self_t |
Public Types inherited from Comparator< typename IdAdapter< T > ::key_t > | |
typedef typename IdAdapter< T > ::key_t | t |
Public Member Functions | |
GenTree (void) | |
GenTree (const GenTree< T > &tree) | |
~GenTree (void) | |
const C & | comparator () const |
C & | comparator () |
const A & | allocator () const |
A & | allocator () |
T * | get (const typename K::key_t &key) |
const T * | get (const typename K::key_t &key) const |
void | set (const T &item) |
void | removeByKey (const typename K::key_t &item) |
int | count (void) const |
bool | contains (const typename K::key_t &item) const |
template<class CC > | |
bool | containsAll (const CC &c) const |
bool | isEmpty (void) const |
operator bool (void) const | |
Iter | begin (void) const |
Iter | end (void) const |
bool | equals (const GenTree< T, K, C > &tree) const |
bool | operator== (const GenTree< T, K, C > &tree) const |
bool | operator!= (const GenTree< T, K, C > &tree) const |
void | clear (void) |
void | add (const T &item) |
template<class CC > | |
void | addAll (const CC &c) |
void | remove (const T &x) |
template<class CC > | |
void | removeAll (const CC &c) |
void | remove (const Iter &iter) |
self_t & | operator+= (const T &x) |
self_t & | operator-= (const T &x) |
void | copy (const GenTree< T, K, C > &tree) |
GenTree< T, K, C > & | operator= (const GenTree< T, K, C > &tree) |
Public Member Functions inherited from AbstractTree | |
int | count (void) const |
Public Member Functions inherited from Comparator< typename IdAdapter< T > ::key_t > | |
int | doCompare (const typename IdAdapter< T > ::key_t &v1, const typename IdAdapter< T > ::key_t &v2) const |
Public Member Functions inherited from DefaultAllocatorDelegate | |
t::ptr | allocate (t::size size) const |
void | free (t::ptr p) const |
template<class T > | |
T * | alloc () const |
Protected Member Functions | |
Node * | root (void) const |
void | remove (Stack &s, Node *n) |
int | compare (const typename K::key_t &k1, const typename K::key_t &k2) const |
Node * | lookup (Stack &s, const typename K::key_t &key) const |
Node * | find (const typename K::key_t &key) const |
void | exchange (Node *n, Node *p) |
Protected Member Functions inherited from AbstractTree | |
AbstractTree (void) | |
Node ** | link (const Stack &s) |
void | exchange (Node *n, Node *m) |
void | insert (Stack &stack, Node *node) |
void | rotateRight (Stack &s) |
void | rotateLeft (Stack &s) |
void | remove (Stack &stack, Node *n) |
Node * | leftMost (Stack &s, Node *n) |
Additional Inherited Members | |
Static Public Member Functions inherited from Comparator< typename IdAdapter< T > ::key_t > | |
static int | compare (const typename IdAdapter< T > ::key_t &v1, const typename IdAdapter< T > ::key_t &v2) |
Protected Types inherited from AbstractTree | |
enum | dir_t { LEFT = -1, NONE = 0, RIGHT = +1 } |
typedef signed char | balance_t |
Protected Attributes inherited from AbstractTree | |
Node * | _root |
int | _cnt |
Static Protected Attributes inherited from AbstractTree | |
static const int | MAX_HEIGHT = 32 |
This class implements an AVL tree collection based on C++ templates as provided by: Ben Pfaff, "An Introduction to Binary Search Trees and Balanced Trees", Libavl Binary Search Tree Library, Volume 1: Source Code, Version 2.0.2.
T | Type of contained items. |
C | Comparator for T items (default to elm::Comparator<T>). |
typedef T t |
|
inline |
Add an item to the tree. Note that the item is still added even if it is already contained in the tree, leading to duplicates.
item | Item to add. |
Referenced by GenTree< T, IdAdapter< T >, elm::Comparator< T > >::addAll(), Set< T, C >::insert(), Set< T, C >::join(), GenTree< T, IdAdapter< T >, elm::Comparator< T > >::operator+=(), Queue< T, C, A >::put(), and GenTree< T, IdAdapter< T >, elm::Comparator< T > >::set().
|
inline |
Add a collection to this tree.
coll | Collection to add. |
C | Type of the collection. |
|
inline |
|
inline |
Referenced by Set< T, C >::subsetOf().
Remove all items from the tree and let it cleared.
Referenced by Map< Pair< K, K >, T, segment_comparator_t >::clear(), GenTree< T, IdAdapter< T >, elm::Comparator< T > >::copy(), Queue< T, C, A >::reset(), and GenTree< T, IdAdapter< T >, elm::Comparator< T > >::~GenTree().
|
inline |
|
inline |
Referenced by Map< Pair< K, K >, T, segment_comparator_t >::comparator().
|
inlineprotected |
|
inline |
Test if the tree contains the given item.
item | Item to look for. |
Referenced by GenTree< T, IdAdapter< T >, elm::Comparator< T > >::containsAll().
|
inline |
Test if the given collection is contained in the current one.
coll | Collection to test. |
C | Type of the collection. |
|
inline |
Get the count of items in the tree.
Referenced by Map< Pair< K, K >, T, segment_comparator_t >::count().
Referenced by GenTree< T, IdAdapter< T >, elm::Comparator< T > >::remove().
|
inlineprotected |
|
inline |
|
inline |
Test if the tree is empty.
Referenced by Map< Pair< K, K >, T, segment_comparator_t >::isEmpty(), and GenTree< T, IdAdapter< T >, elm::Comparator< T > >::operator bool().
|
inline |
|
inline |
Referenced by GenTree< T, IdAdapter< T >, elm::Comparator< T > >::remove().
|
inline |
Remove an item from a tree. Notice that if the tree contains duplicates of the item, only the first duplicate is removed.
item | Item to remove. |
Referenced by Set< T, C >::diff(), Queue< T, C, A >::get(), Set< T, C >::operator-=(), GenTree< T, IdAdapter< T >, elm::Comparator< T > >::operator-=(), Map< Pair< K, K >, T, segment_comparator_t >::remove(), GenTree< T, IdAdapter< T >, elm::Comparator< T > >::removeAll(), and GenTree< T, IdAdapter< T >, elm::Comparator< T > >::removeByKey().
|
inline |
Remove a collection from this tree.
coll | Collection to remove. |
C | Type of the collection. |
|
inline |
Referenced by GenTree< T, IdAdapter< T >, elm::Comparator< T > >::clear(), GenTree< T, IdAdapter< T >, elm::Comparator< T > >::copy(), GenTree< T, IdAdapter< T >, elm::Comparator< T > >::find(), Queue< T, C, A >::get(), Queue< T, C, A >::head(), GenTree< T, K, C, A >::Iter::Iter(), and GenTree< T, IdAdapter< T >, elm::Comparator< T > >::lookup().
|
inline |
Referenced by Map< Pair< K, K >, T, segment_comparator_t >::put().