File Information
Library: Foundation
Package: Hashing
Header: Poco/SimpleHashTable.h
Deprecated. This class issc_deprecated.
Description
A SimpleHashTable stores a key value pair that can be looked up via a hashed key.
In comparison to a HashTable, this class handles collisions by sequentially searching the next free location. This also means that the maximum size of this table is limited, i.e. if the hash table is full, it will throw an exception and that this class does not support remove operations. On the plus side it is faster than the HashTable.
This class is NOT thread safe.
Member Summary
Member Functions: capacity, clear, currentState, exists, existsRaw, get, getKeyRaw, getRaw, hash, insert, insertRaw, operator =, operator [], resize, size, swap, update, updateRaw
Nested Classes
class HashEntry
Types
HashTableVector
typedef std::vector < HashEntry * > HashTableVector;
Constructors
SimpleHashTable
SimpleHashTable(
UInt32 capacity = 251
);
Creates the SimpleHashTable.
SimpleHashTable
SimpleHashTable(
const SimpleHashTable & ht
);
Destructor
~SimpleHashTable
~SimpleHashTable();
Destroys the SimpleHashTable.
Member Functions
capacity
UInt32 capacity() const;
clear
void clear();
currentState
HashStatistic currentState(
bool details = false
) const;
Returns the current internal state
exists
bool exists(
const Key & key
) const;
existsRaw
bool existsRaw(
const Key & key,
UInt32 hsh
) const;
get
const Value & get(
const Key & key
) const;
Throws an exception if the value does not exist
get
Value & get(
const Key & key
);
Throws an exception if the value does not exist
get
bool get(
const Key & key,
Value & v
) const;
Sets v to the found value, returns false if no value was found
getKeyRaw
const Key & getKeyRaw(
const Key & key,
UInt32 hsh
);
Throws an exception if the key does not exist. returns a reference to the internally stored key. Useful when someone does an insert and wants for performance reason only to store a pointer to the key in another collection
getRaw
const Value & getRaw(
const Key & key,
UInt32 hsh
) const;
Throws an exception if the value does not exist
getRaw
bool getRaw(
const Key & key,
UInt32 hsh,
Value & v
) const;
Sets v to the found value, returns false if no value was found
hash
UInt32 hash(
const Key & key
) const;
insert
UInt32 insert(
const Key & key,
const Value & value
);
Returns the hash value of the inserted item. Throws an exception if the entry was already inserted
insertRaw
Value & insertRaw(
const Key & key,
UInt32 hsh,
const Value & value
);
Returns the hash value of the inserted item. Throws an exception if the entry was already inserted
operator =
SimpleHashTable & operator = (
const SimpleHashTable & ht
);
operator []
const Value & operator[] (
const Key & key
) const;
operator []
Value & operator[] (
const Key & key
);
resize
void resize(
UInt32 newSize
);
Resizes the hashtable, rehashes all existing entries. Expensive!
size
std::size_t size() const;
Returns the number of elements already inserted into the SimpleHashTable
swap
void swap(
SimpleHashTable & ht
) noexcept;
update
UInt32 update(
const Key & key,
const Value & value
);
Returns the hash value of the inserted item. Replaces an existing entry if it finds one
updateRaw
void updateRaw(
const Key & key,
UInt32 hsh,
const Value & value
);
Returns the hash value of the inserted item. Replaces an existing entry if it finds one