|
libircbot
library providing a framework for implementing an IRC bot
|
A hash table storing any data objects using string keys. More...
#include <ircbot/hashtable.h>
Public Member Functions | |
| IBHashTable * | IBHashTable_create (uint8_t bits) |
| IBHashTable default constructor. More... | |
| void | IBHashTable_set (IBHashTable *self, const char *key, void *obj, void(*deleter)(void *)) |
| Set a new object for a key. More... | |
| int | IBHashTable_delete (IBHashTable *self, const char *key) |
| Deletes the object with the specified key. More... | |
| size_t | IBHashTable_count (const IBHashTable *self) |
| Number of entries. More... | |
| void * | IBHashTable_get (const IBHashTable *self, const char *key) |
| Gets an object by key. More... | |
| IBHashTableIterator * | IBHashTable_iterator (const IBHashTable *self) |
| Creates an iterator for all entries. More... | |
| void | IBHashTable_destroy (IBHashTable *self) |
| IBHashTable destructor. More... | |
A hash table storing any data objects using string keys.
| size_t IBHashTable_count | ( | const IBHashTable * | self | ) |
| IBHashTable * IBHashTable_create | ( | uint8_t | bits | ) |
IBHashTable default constructor.
Creates a new IBHashTable
| bits | number of bits for the hashes (valid range [2..8]) |
| int IBHashTable_delete | ( | IBHashTable * | self, |
| const char * | key | ||
| ) |
Deletes the object with the specified key.
If the object has a deleter attached, it is also destroyed.
| self | the IBHashTable |
| key | the key |
| void IBHashTable_destroy | ( | IBHashTable * | self | ) |
IBHashTable destructor.
All stored objects that have a deleter attached are destroyed as well.
| self | the IBHashTable |
| void * IBHashTable_get | ( | const IBHashTable * | self, |
| const char * | key | ||
| ) |
Gets an object by key.
| self | the IBHashTable |
| key | the key |
| IBHashTableIterator * IBHashTable_iterator | ( | const IBHashTable * | self | ) |
Creates an iterator for all entries.
The iterator contains a snapshot of all objects currently stored, modifications to the IBHashTable will not be reflected in the iterator. In its initial state, the iterator points to an invalid position.
| self | the IBHashTable |
| void IBHashTable_set | ( | IBHashTable * | self, |
| const char * | key, | ||
| void * | obj, | ||
| void(*)(void *) | deleter | ||
| ) |
Set a new object for a key.
If there was already an object for the given key, it is replaced. The old object is destroyed if it has a deleter attached.
| self | the IBHashTable |
| key | the key |
| obj | the new object |
| deleter | optional function to destroy the object |