Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
HashTable< T, H, A > Class Template Reference

#include <elm/data/HashTable.h>

+ Inheritance diagram for HashTable< T, H, A >:

Classes

class  Iter
 

Public Types

typedef HashTable< T, H, A > self_t
 

Public Member Functions

 HashTable (int _size=211)
 
 HashTable (const self_t &h)
 
 ~HashTable (void)
 
const H & hash () const
 
H & hash ()
 
const A & allocator () const
 
A & allocator ()
 
const T * get (const T &key) const
 
const T * get_const (const T &key) const
 
bool hasKey (const T &key) const
 
bool hasKey_const (const T &key) const
 
bool exists (const T &key) const
 
bool exists_const (const T &key) const
 
void put (const T &data)
 
template<class CC >
void putAll (const CC &c)
 
bool isEmpty (void) const
 
 operator bool () const
 
int count (void) const
 
bool contains (const T &x) const
 
bool contains_const (const T &x) const
 
template<class CC >
bool containsAll (const CC &c) const
 
template<class CC >
bool containsAll_const (const CC &c) const
 
Iter begin () const
 
Iter end () const
 
bool equals (const HashTable< T > &h) const
 
bool equals_const (const HashTable< T > &h) const
 
bool operator== (const HashTable< T > &t) const
 
bool operator!= (const HashTable< T > &t) const
 
void clear (void)
 
T * add (const T &data)
 
self_toperator+= (const T &x)
 
template<class C >
void addAll (const C &c)
 
void remove (const T &key)
 
template<class C >
void removeAll (const C &c)
 
self_toperator-= (const T &x)
 
void remove (const Iter &i)
 
void copy (const HashTable< T, H > &t)
 
self_toperator= (const HashTable< T, H > &c)
 
T * get (const T &key)
 
- Public Member Functions inherited from HashKey< T >
t::hash computeHash (const T &key) const
 
bool isEqual (const T &key1, const T &key2) 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_t * find (const T &key) const
 
node_t * find_const (const T &key) const
 

Additional Inherited Members

- Static Public Member Functions inherited from HashKey< T >
static t::hash hash (const T &key)
 
static bool equals (const T &key1, const T &key2)
 

Detailed Description

template<class T, class H = HashKey<T>, class A = DefaultAlloc>
class elm::HashTable< T, H, A >

This class provides an hashing table implementation as an array of linked list. A small caching feature put to the head of the linked list last accessed items.

This class is the basic implementation of hash table. To use it as a map, refer to HashMap. To use it as a set, refer to HashSet.

Parameters
TType of stored data.
AAdapter to access key information (must implement concept::Adapter).
MManager of the hash table providing hashing and allocation services.
Deprecated:
Use HashMap instead.

Member Typedef Documentation

◆ self_t

typedef HashTable<T, H, A> self_t

Constructor & Destructor Documentation

◆ HashTable() [1/2]

HashTable ( int  size = 211)
inline

Build an hash table with the given size. Improved efficiency is obtained with prime number as sizes.

Parameters
sizeTable size (default to 211).

◆ HashTable() [2/2]

HashTable ( const self_t h)
inline

◆ ~HashTable()

~HashTable ( void  )
inline

Member Function Documentation

◆ add()

◆ addAll()

void addAll ( const C &  c)
inline

◆ allocator() [1/2]

A& allocator ( )
inline

◆ allocator() [2/2]

const A& allocator ( ) const
inline

◆ begin()

Iter begin ( ) const
inline

◆ clear()

◆ contains()

◆ contains_const()

◆ containsAll()

◆ containsAll_const()

◆ copy()

◆ count()

int count ( void  ) const
inline

Count the number of items in the table.

Returns
Count of items.

Referenced by HashSet< T, H, A >::count(), and HashMap< elm::CString, void * >::count().

◆ end()

Iter end ( ) const
inline

◆ equals()

◆ equals_const()

bool equals_const ( const HashTable< T > &  h) const
inline

◆ exists()

bool exists ( const T &  key) const
inline

Same as hasKey().

◆ exists_const()

bool exists_const ( const T &  key) const
inline

◆ find()

◆ find_const()

◆ get() [1/2]

T* get ( const T &  key)
inline

◆ get() [2/2]

◆ get_const()

const T* get_const ( const T &  key) const
inline

◆ hash() [1/2]

H& hash ( )
inline

◆ hash() [2/2]

const H& hash ( ) const
inline

◆ hasKey()

bool hasKey ( const T &  key) const
inline

Test if a key is in the table.

Parameters
keyTested key.
Returns
True if there is an item in the table with the given key, false else.

Referenced by HashSet< T, H, A >::contains(), HashTable< Pair< const void *, bool >, AssocHashKey< const void *, bool, HashKey< const void * > >, DefaultAlloc >::exists(), and HashMap< elm::CString, void * >::hasKey().

◆ hasKey_const()

◆ isEmpty()

bool isEmpty ( void  ) const
inline

◆ operator bool()

operator bool ( ) const
inline

◆ operator!=()

bool operator!= ( const HashTable< T > &  t) const
inline

◆ operator+=()

self_t& operator+= ( const T &  x)
inline

◆ operator-=()

self_t& operator-= ( const T &  x)
inline

◆ operator=()

self_t& operator= ( const HashTable< T, H > &  c)
inline

◆ operator==()

bool operator== ( const HashTable< T > &  t) const
inline

◆ put()

void put ( const T &  data)
inline

Add a data in the table ensuring there is only one data with the corresponding key.

Parameters
dataAdded data.

Referenced by HashSet< T, H, A >::insert(), HashMap< elm::CString, void * >::put(), and HashTable< Pair< const void *, bool >, AssocHashKey< const void *, bool, HashKey< const void * > >, DefaultAlloc >::putAll().

◆ putAll()

◆ remove() [1/2]

void remove ( const Iter i)
inline

◆ remove() [2/2]

◆ removeAll()

void removeAll ( const C &  c)
inline

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