RAVE
|
Implementation of a rave object hashtable that maps between strings and rave core objects. More...
#include "raveobject_hashtable.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include <string.h>
#include <stdio.h>
Classes | |
struct | RaveHash_bucket |
struct | _RaveObjectHashTable_t |
Represents a hash table. More... | |
Macros | |
#define | INITIAL_BUCKET_COUNT 10 |
Typedefs | |
typedef struct RaveHash_bucket | RaveHash_bucket |
Functions | |
int | RaveObjectHashTable_put (RaveObjectHashTable_t *table, const char *key, RaveCoreObject *obj) |
Inserts a key - object binding in the table. | |
RaveCoreObject * | RaveObjectHashTable_get (RaveObjectHashTable_t *table, const char *key) |
Returns the object referred to by key. | |
int | RaveObjectHashTable_size (RaveObjectHashTable_t *table) |
Returns the number of items in this table. | |
int | RaveObjectHashTable_exists (RaveObjectHashTable_t *table, const char *key) |
Returns if the specified key exists or not. | |
RaveCoreObject * | RaveObjectHashTable_remove (RaveObjectHashTable_t *table, const char *key) |
Removes the item with the specified key and returns it. | |
void | RaveObjectHashTable_clear (RaveObjectHashTable_t *table) |
Clears all entries in the table. | |
RaveList_t * | RaveObjectHashTable_keys (RaveObjectHashTable_t *table) |
Returns the keys for the table at the current state. | |
RaveObjectList_t * | RaveObjectHashTable_values (RaveObjectHashTable_t *table) |
Returns the values for the table. | |
void | RaveObjectHashTable_destroyKeyList (RaveList_t *l) |
Helper function to destroy the returned list of keys. | |
Variables | |
RaveCoreObjectType | RaveObjectHashTable_TYPE |
Type definition to use when creating a rave object. | |
Implementation of a rave object hashtable that maps between strings and rave core objects.
This object supports RAVE_OBJECT_CLONE with an exception, if any members of the list is not possible to clone, they will not be added to the list which means that the returned list might have fewer entries.
void RaveObjectHashTable_clear | ( | RaveObjectHashTable_t * | table | ) |
Clears all entries in the table.
[in] | table | - the table |
void RaveObjectHashTable_destroyKeyList | ( | RaveList_t * | l | ) |
Helper function to destroy the returned list of keys.
[in] | l | - the list to destroy |
int RaveObjectHashTable_exists | ( | RaveObjectHashTable_t * | table, |
const char * | key ) |
Returns if the specified key exists or not.
[in] | table | - self |
[in] | key | - the key to search for |
RaveCoreObject * RaveObjectHashTable_get | ( | RaveObjectHashTable_t * | table, |
const char * | key ) |
Returns the object referred to by key.
[in] | table | - the table |
[in] | key | - the key |
RaveList_t * RaveObjectHashTable_keys | ( | RaveObjectHashTable_t * | table | ) |
Returns the keys for the table at the current state.
Note, remember to deallocate keys appropriately after retrival or use the function @ref RaveList_freeAndDestroy that will take care of it for you.
[in] | table | - self |
int RaveObjectHashTable_put | ( | RaveObjectHashTable_t * | table, |
const char * | key, | ||
RaveCoreObject * | obj ) |
Inserts a key - object binding in the table.
[in] | table | - the table |
[in] | key | - the key |
[in] | obj | - the object |
RaveCoreObject * RaveObjectHashTable_remove | ( | RaveObjectHashTable_t * | table, |
const char * | key ) |
Removes the item with the specified key and returns it.
[in] | table | - the table |
[in] | key | - the key |
int RaveObjectHashTable_size | ( | RaveObjectHashTable_t * | table | ) |
Returns the number of items in this table.
[in] | table | - the table |
RaveObjectList_t * RaveObjectHashTable_values | ( | RaveObjectHashTable_t * | table | ) |
Returns the values for the table.
Note, it is not cloned values but references to them.
[in] | table | - self |
RaveCoreObjectType RaveObjectHashTable_TYPE |
Type definition to use when creating a rave object.