Logo Search packages:      
Sourcecode: poco version File versions  Download package

Public Types | Public Member Functions | Private Attributes

Poco::HashTable< Key, Value, KeyHashFunction > Class Template Reference

#include <HashTable.h>

Collaboration diagram for Poco::HashTable< Key, Value, KeyHashFunction >:
Collaboration graph

List of all members.

Public Types

typedef std::map< Key, Value > HashEntryMap
typedef HashEntryMap ** HashTableVector
typedef HashEntryMap::iterator Iterator

Public Member Functions

void clear ()
HashStatistic currentState (bool details=false) const
 Returns the current internal state.
bool exists (const Key &key)
bool existsRaw (const Key &key, UInt32 hsh)
bool get (const Key &key, Value &v) const
 Sets v to the found value, returns false if no value was found.
const Value & get (const Key &key) const
 Throws an exception if the value does not exist.
Value & get (const Key &key)
 Throws an exception if the value does not exist.
const Key & getKeyRaw (const Key &key, UInt32 hsh)
bool getRaw (const Key &key, UInt32 hsh, Value &v) const
 Sets v to the found value, returns false if no value was found.
const Value & getRaw (const Key &key, UInt32 hsh) const
 Throws an exception if the value does not exist.
UInt32 hash (const Key &key) const
 HashTable (UInt32 initialSize=251)
 HashTable (const HashTable &ht)
UInt32 insert (const Key &key, const Value &value)
Value & insertRaw (const Key &key, UInt32 hsh, const Value &value)
UInt32 maxCapacity () const
HashTableoperator= (const HashTable &ht)
const Value & operator[] (const Key &key) const
Value & operator[] (const Key &key)
void remove (const Key &key)
void removeRaw (const Key &key, UInt32 hsh)
 Performance version, allows to specify the hash value.
void resize (UInt32 newSize)
 Resizes the hashtable, rehashes all existing entries. Expensive!
std::size_t size () const
 Returns the number of elements already inserted into the HashTable.
UInt32 update (const Key &key, const Value &value)
void updateRaw (const Key &key, UInt32 hsh, const Value &value)
 ~HashTable ()
 Destroys the HashTable.

Private Attributes

HashTableVector _entries
KeyHashFunction _hash
UInt32 _maxCapacity
std::size_t _size

Detailed Description

template<class Key, class Value, class KeyHashFunction = HashFunction<Key>>
class Poco::HashTable< Key, Value, KeyHashFunction >

A HashTable stores a key value pair that can be looked up via a hashed key.

Collision handling is done via overflow maps(!). With small hash tables performance of this data struct will be closer to that a map than a hash table, i.e. slower. On the plus side, this class offers remove operations. Also HashTable full errors are not possible. If a fast HashTable implementation is needed and the remove operation is not required, use SimpleHashTable instead.

This class is NOT thread safe.

Definition at line 58 of file HashTable.h.

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

Generated by  Doxygen 1.6.0   Back to index