Torque2D Reference
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
HashTable< Key, Value > Class Template Reference

#include <hashTable.h>

+ Inheritance diagram for HashTable< Key, Value >:

Classes

class  _Iterator
 
struct  Pair
 

Public Types

typedef Pair ValueType
 
typedef PairReference
 
typedef const PairConstReference
 
typedef S32 DifferenceType
 
typedef U32 SizeType
 
typedef _Iterator< Pair, Node, HashTableiterator
 
typedef _Iterator< const Pair, const Node, const HashTableconst_iterator
 

Public Member Functions

 HashTable ()
 
 ~HashTable ()
 
 HashTable (const HashTable &p)
 
U32 size () const
 Return the number of elements.
 
U32 tableSize () const
 Return the size of the hash bucket table.
 
void clear ()
 Empty the HashTable.
 
void resize (U32 size)
 
bool isEmpty () const
 Returns true if the table is empty.
 
F32 collisions () const
 Returns the average number of nodes per bucket.
 
iterator insertEqual (const Key &key, const Value &)
 
iterator insertUnique (const Key &key, const Value &)
 
void erase (iterator)
 Erase the given entry.
 
void erase (const Key &key)
 Erase all matching keys from the table.
 
iterator findOrInsert (const Key &key)
 
iterator find (const Key &)
 Find the first entry for the given key.
 
const_iterator find (const Key &) const
 Find the first entry for the given key.
 
S32 count (const Key &)
 Count the number of matching keys in the table.
 
iterator begin ()
 iterator to first element
 
const_iterator begin () const
 iterator to first element
 
iterator end ()
 iterator to last element + 1
 
const_iterator end () const
 iterator to last element + 1
 
void operator= (const HashTable &p)
 

Detailed Description

template<typename Key, typename Value>
class HashTable< Key, Value >

A HashTable template class.

The hash table class maps between a key and an associated value. Access using the key is performed using a hash table. The class provides methods for both unique and equal keys. The global ::hash(Type) function is used for hashing, see util/hash.h

Member Typedef Documentation

◆ const_iterator

template<typename Key , typename Value >
typedef _Iterator<const Pair,const Node,const HashTable> const_iterator

◆ ConstReference

template<typename Key , typename Value >
typedef const Pair& ConstReference

◆ DifferenceType

template<typename Key , typename Value >
typedef S32 DifferenceType

◆ iterator

template<typename Key , typename Value >
typedef _Iterator<Pair,Node,HashTable> iterator

◆ Reference

template<typename Key , typename Value >
typedef Pair& Reference

◆ SizeType

template<typename Key , typename Value >
typedef U32 SizeType

◆ ValueType

template<typename Key , typename Value >
typedef Pair ValueType

Constructor & Destructor Documentation

◆ HashTable() [1/2]

template<typename Key , typename Value >
HashTable ( )

◆ ~HashTable()

template<typename Key , typename Value >
~HashTable ( )

◆ HashTable() [2/2]

template<typename Key , typename Value >
HashTable ( const HashTable< Key, Value > &  p)

Member Function Documentation

◆ begin() [1/2]

template<typename Key , typename Value >
HashTable< Key, Value >::iterator begin ( )
inline

iterator to first element

◆ begin() [2/2]

template<typename Key , typename Value >
HashTable< Key, Value >::const_iterator begin ( ) const
inline

iterator to first element

◆ clear()

template<typename Key , typename Value >
void clear ( )
inline

Empty the HashTable.

◆ collisions()

template<typename Key , typename Value >
F32 collisions ( ) const
inline

Returns the average number of nodes per bucket.

◆ count()

template<typename Key , typename Value >
S32 count ( const Key &  key)

Count the number of matching keys in the table.

◆ end() [1/2]

template<typename Key , typename Value >
HashTable< Key, Value >::iterator end ( )
inline

iterator to last element + 1

◆ end() [2/2]

template<typename Key , typename Value >
HashTable< Key, Value >::const_iterator end ( ) const
inline

iterator to last element + 1

◆ erase() [1/2]

template<typename Key , typename Value >
void erase ( const Key &  key)

Erase all matching keys from the table.

◆ erase() [2/2]

template<typename Key , typename Value >
void erase ( iterator  node)

Erase the given entry.

◆ find() [1/2]

template<typename Key , typename Value >
HashTable< Key, Value >::iterator find ( const Key &  key)

Find the first entry for the given key.

◆ find() [2/2]

template<typename Key , typename Value >
const_iterator find ( const Key &  ) const

Find the first entry for the given key.

◆ findOrInsert()

template<typename Key , typename Value >
HashTable< Key, Value >::iterator findOrInsert ( const Key &  key)

Find the key, or insert a one if it doesn't exist. Returns the first key in the table that matches, or inserts one if there are none.

◆ insertEqual()

template<typename Key , typename Value >
HashTable< Key, Value >::iterator insertEqual ( const Key &  key,
const Value &  x 
)

Insert the key value pair and allow duplicates. This insert method allows duplicate keys. Keys are grouped together but are not sorted.

◆ insertUnique()

template<typename Key , typename Value >
HashTable< Key, Value >::iterator insertUnique ( const Key &  key,
const Value &  x 
)

Insert the key value pair but don't insert duplicates. This insert method does not insert duplicate keys. If the key already exists in the table the function will fail and end() is returned.

◆ isEmpty()

template<typename Key , typename Value >
bool isEmpty ( ) const
inline

Returns true if the table is empty.

◆ operator=()

template<typename Key , typename Value >
void operator= ( const HashTable< Key, Value > &  p)

◆ resize()

template<typename Key , typename Value >
void resize ( U32  size)
inline

Resize the bucket table for an estimated number of elements. This method will optimize the hash bucket table size to hold the given number of elements. The size argument is a hint, and will not be the exact size of the table. If the table is sized down below it's optimal size, the next insert will cause it to be resized again. Normally this function is used to avoid resizes when the number of elements that will be inserted is known in advance.

◆ size()

template<typename Key , typename Value >
U32 size ( ) const
inline

Return the number of elements.

◆ tableSize()

template<typename Key , typename Value >
U32 tableSize ( ) const
inline

Return the size of the hash bucket table.


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