FreeNOS
|
Efficient key -> value lookups. More...
#include <HashTable.h>
Data Structures | |
class | Bucket |
Describes a bucket in the HashTable, for collision avoidance. More... | |
Public Member Functions | |
HashTable (Size size=HASHTABLE_DEFAULT_SIZE) | |
Class constructor. More... | |
virtual bool | insert (const K &key, const V &value) |
Inserts the given item to the HashTable. More... | |
virtual bool | append (const K &key, const V &value) |
Append a new item. More... | |
virtual int | remove (const K &key) |
Remove value(s) for the given key. More... | |
virtual Size | size () const |
Get the size of the HashTable. More... | |
virtual Size | count () const |
Get the number of values stored in the HashTable. More... | |
virtual List< K > | keys () const |
Retrieve all keys inside the Association. More... | |
virtual List< K > | keys (const V &value) const |
Retrieve list of Keys for the given value. More... | |
virtual List< V > | values () const |
Retrieve all values inside the Association. More... | |
virtual List< V > | values (const K &key) const |
Retrieve values for the given key inside the Association. More... | |
virtual const V * | get (const K &key) const |
Returns the first value for the given key. More... | |
virtual const V & | at (const K &key) const |
Returns a reference to the first value for the given key. More... | |
virtual const V | value (const K &key, const V defaultValue=V()) const |
Return the first value for the given key. More... | |
Vector< List< Bucket > > & | table () |
Get the internal Vector with Buckets. More... | |
V & | operator[] (const K &key) |
Modifiable index operator. More... | |
const V & | operator[] (const K &key) const |
Constant index operator. More... | |
Public Member Functions inherited from Associative< K, V > | |
virtual void | clear () |
Removes all items from the Association. More... | |
virtual bool | contains (const K &key) const |
Check if the given key exists. More... | |
virtual int | compareTo (const Associative< K, V > &a) const |
Compare this instance to another instance. More... | |
virtual bool | equals (const Associative< K, V > &a) const |
Test if an Associative is equal to an other Associative. More... | |
const V & | operator[] (K key) const |
Returns the first value for the given key. More... | |
Public Member Functions inherited from Container | |
Container () | |
Constructor. More... | |
virtual | ~Container () |
Destructor. More... | |
virtual bool | isEmpty () const |
Check if the Container is empty. More... | |
virtual bool | reserve (Size size) |
Ensure that at least the given size is available. More... | |
virtual bool | shrink (Size size) |
Shrink the container size by the given amount of items. More... | |
virtual Size | squeeze () |
Try to minimize the memory required in the Container. More... | |
virtual bool | resize (Size size) |
Change the size of the Container. More... | |
Public Member Functions inherited from Comparable< Associative< K, V > > | |
virtual | ~Comparable () |
Class destructor. More... | |
Private Attributes | |
Vector< List< Bucket > > | m_table |
Internal table. More... | |
Size | m_count |
Number of values in the buckets. More... | |
Efficient key -> value lookups.
Definition at line 44 of file HashTable.h.
|
inline |
Class constructor.
size | Initial size of the internal table. |
Definition at line 111 of file HashTable.h.
|
inlinevirtual |
Append a new item.
key | Associated key. |
value | New item to append. |
Reimplemented from Associative< K, V >.
Definition at line 162 of file HashTable.h.
|
inlinevirtual |
Returns a reference to the first value for the given key.
key | Key to find. |
Implements Associative< K, V >.
Definition at line 307 of file HashTable.h.
Referenced by HashTable< String, FileCache * >::operator[]().
Get the number of values stored in the HashTable.
Implements Container.
Definition at line 211 of file HashTable.h.
Referenced by FileSystemServer::clearFileCache(), ArgumentParser::getUsage(), and FileSystemServer::unregisterFile().
|
inlinevirtual |
Returns the first value for the given key.
key | Key to find. |
Implements Associative< K, V >.
Definition at line 287 of file HashTable.h.
Referenced by ArgumentContainer::get(), DatastoreServer::getBufferTable(), Shell::getCommand(), ChannelRegistry::getConsumer(), FileSystemServer::getNextInode(), ChannelRegistry::getProducer(), FileSystemServer::inodeHandler(), ArgumentParser::parse(), UDP::process(), DatastoreServer::registerBuffer(), and FileSystemServer::waitFileHandler().
|
inlinevirtual |
Inserts the given item to the HashTable.
If an item exists for the given key, its value will be replaced.
key | The associated key for the given item to use. |
value | The item to insert |
Reimplemented from Associative< K, V >.
Definition at line 133 of file HashTable.h.
Referenced by ArgumentContainer::addFlag(), UDP::bind(), FileCache::FileCache(), DatastoreServer::getBufferTable(), LinnFileSystem::getInode(), FileSystemServer::insertFileCache(), FileSystemServer::lookupFile(), DatastoreServer::registerBuffer(), Shell::registerCommand(), ChannelRegistry::registerConsumer(), ArgumentParser::registerFlag(), and ChannelRegistry::registerProducer().
Retrieve all keys inside the Association.
Implements Associative< K, V >.
Definition at line 221 of file HashTable.h.
|
inlinevirtual |
Retrieve list of Keys for the given value.
Implements Associative< K, V >.
Definition at line 236 of file HashTable.h.
|
inline |
Modifiable index operator.
Definition at line 349 of file HashTable.h.
|
inline |
Constant index operator.
Definition at line 357 of file HashTable.h.
|
inlinevirtual |
Remove value(s) for the given key.
key | Associated key. |
Reimplemented from Associative< K, V >.
Definition at line 178 of file HashTable.h.
Referenced by FileSystemServer::clearFileCache(), ChannelRegistry::unregisterConsumer(), and ChannelRegistry::unregisterProducer().
Get the size of the HashTable.
Implements Container.
Definition at line 201 of file HashTable.h.
Referenced by HashTable< String, FileCache * >::HashTable().
Get the internal Vector with Buckets.
Definition at line 341 of file HashTable.h.
|
inlinevirtual |
Return the first value for the given key.
If the key is not found, the default value is returned.
Implements Associative< K, V >.
Definition at line 325 of file HashTable.h.
Referenced by HashTable< String, FileCache * >::append(), FileSystemServer::findFileCache(), LinnFileSystem::getInode(), HashTable< String, FileCache * >::insert(), HashTable< String, FileCache * >::keys(), and FileSystemServer::lookupFile().
Retrieve all values inside the Association.
Implements Associative< K, V >.
Definition at line 253 of file HashTable.h.
|
inlinevirtual |
Retrieve values for the given key inside the Association.
Implements Associative< K, V >.
Definition at line 269 of file HashTable.h.
Number of values in the buckets.
Definition at line 368 of file HashTable.h.
Referenced by HashTable< String, FileCache * >::append(), HashTable< String, FileCache * >::count(), HashTable< String, FileCache * >::HashTable(), HashTable< String, FileCache * >::insert(), and HashTable< String, FileCache * >::remove().
Internal table.
Definition at line 365 of file HashTable.h.
Referenced by HashTable< String, FileCache * >::append(), HashTable< String, FileCache * >::at(), HashTable< String, FileCache * >::get(), HashTable< String, FileCache * >::HashTable(), HashTable< String, FileCache * >::insert(), HashTable< String, FileCache * >::keys(), HashTable< String, FileCache * >::remove(), HashTable< String, FileCache * >::size(), HashTable< String, FileCache * >::table(), HashTable< String, FileCache * >::value(), and HashTable< String, FileCache * >::values().