Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::avl::GenTree< T, K, C > Class Template Reference

#include <elm/avl/GenTree.h>

+ Inheritance diagram for elm::avl::GenTree< T, K, C >:

Classes

class  Iterator
 
class  Node
 

Public Member Functions

 GenTree (void)
 
 GenTree (const GenTree< T > &tree)
 
 ~GenTree (void)
 
T * get (const typename K::key_t &key)
 
const T * get (const typename K::key_t &key) const
 
int count (void) const
 
bool contains (const typename K::key_t &item) const
 
bool isEmpty (void) const
 
 operator bool (void) const
 
template<template< class _ > class Co>
bool containsAll (const Co< T > &coll) const
 
void clear (void)
 
void copy (const GenTree< T, K, C > &tree)
 
GenTree< T, K, C > & operator= (const GenTree< T, K, C > &tree)
 
void add (const T &item)
 
void set (const T &item)
 
void remove (const typename K::key_t &item)
 
void remove (const Iterator &iter)
 
template<class CC >
void addAll (const CC &coll)
 
template<class CC >
void removeAll (const CC &coll)
 
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
 

Protected Member Functions

Nodefind (const typename K::key_t &key) const
 
- Protected Member Functions inherited from elm::avl::AbstractTree
 AbstractTree (void)
 
void insert (unsigned char da[], int dir, Node *node, Node *q, Node *y, Node *z)
 
void remove (Node *pa[], unsigned char da[], int k, Node *p)
 
int count (void) const
 

Additional Inherited Members

- Protected Attributes inherited from elm::avl::AbstractTree
Noderoot
 
int cnt
 

Detailed Description

template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
class elm::avl::GenTree< T, K, C >

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.

This class is rarely used as is but used as a base class for elm::avl::Set or elm::avl::Map.
Parameters
TType of contained items.
CComparator for T items (default to elm::Comparator<T>).
See also
elm::avl::Set, elm::avl::Map
Implemented concepts
  • elm::concept::Collection<T>
  • elm::concept::MutableCollection<T>

Constructor & Destructor Documentation

template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
elm::avl::GenTree< T, K, C >::GenTree ( void  )
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
elm::avl::GenTree< T, K, C >::GenTree ( const GenTree< T > &  tree)
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
elm::avl::GenTree< T, K, C >::~GenTree ( void  )

Member Function Documentation

template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
void elm::avl::GenTree< T, K, C >::add ( const T &  item)

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.

Parameters
itemItem to add.

Referenced by elm::avl::GenTree< T, IdAdapter< T >, C >::addAll(), and elm::genstruct::AVLMap< K, T, C >::put().

template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
template<class CC >
void elm::avl::GenTree< T, K, C >::addAll ( const CC &  coll)

Add a collection to this tree.

Parameters
collCollection to add.
CType of the collection.
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
void elm::avl::GenTree< T, K, C >::clear ( void  )
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
bool elm::avl::GenTree< T, K, C >::contains ( const typename K::key_t &  item) const

Test if the tree contains the given item.

Parameters
itemItem to look for.
Returns
True if it is contained, false else. Access time in log2(item number).

Referenced by elm::avl::GenTree< T, IdAdapter< T >, C >::containsAll().

template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
template<template< class _ > class Co>
bool elm::avl::GenTree< T, K, C >::containsAll ( const Co< T > &  coll) const

Test if the given collection is contained in the current one.

Parameters
collCollection to test.
Returns
True if the collection is containted, false else.
Parameters
CType of the collection.
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
void elm::avl::GenTree< T, K, C >::copy ( const GenTree< T, K, C > &  tree)
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
int elm::avl::GenTree< T, K, C >::count ( void  ) const

Get the count of items in the tree.

Returns
Item count. This function call is fast as the item count is maintained during each insertion and removal.

Referenced by elm::genstruct::AVLMap< K, T, C >::count(), and elm::avl::Map< Pair< K, K >, T, segment_comparator_t >::count().

template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
bool elm::avl::GenTree< T, K, C >::equals ( const GenTree< T, K, C > &  tree) const
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
Node* elm::avl::GenTree< T, K, C >::find ( const typename K::key_t &  key) const
protected
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
T* elm::avl::GenTree< T, K, C >::get ( const typename K::key_t &  key)
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
const T* elm::avl::GenTree< T, K, C >::get ( const typename K::key_t &  key) const
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
bool elm::avl::GenTree< T, K, C >::isEmpty ( void  ) const

Test if the tree is empty.

Returns
True if the tree is empty, false else.

Referenced by elm::avl::Map< Pair< K, K >, T, segment_comparator_t >::isEmpty(), and elm::avl::GenTree< T, IdAdapter< T >, C >::operator bool().

template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
elm::avl::GenTree< T, K, C >::operator bool ( void  ) const
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
bool elm::avl::GenTree< T, K, C >::operator!= ( const GenTree< T, K, C > &  tree) const
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
GenTree<T, K, C>& elm::avl::GenTree< T, K, C >::operator= ( const GenTree< T, K, C > &  tree)
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
bool elm::avl::GenTree< T, K, C >::operator== ( const GenTree< T, K, C > &  tree) const
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
void elm::avl::GenTree< T, K, C >::remove ( const typename K::key_t &  item)
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
void elm::avl::GenTree< T, K, C >::remove ( const Iterator iter)

Remove the item pointed by the iterator.

Parameters
Iteratorpointing to the item to remove.
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
template<class CC >
void elm::avl::GenTree< T, K, C >::removeAll ( const CC &  coll)

Remove a collection from this tree.

Parameters
collCollection to remove.
CType of the collection.
template<class T, class K = IdAdapter<T>, class C = elm::Comparator<typename K::key_t>>
void elm::avl::GenTree< T, K, C >::set ( const T &  item)

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