RAVE
raveobject_hashtable.h File Reference

Implementation of a rave object hashtable that maps between strings and rave core objects. More...

#include "rave_object.h"
#include "rave_list.h"
#include "raveobject_list.h"

Go to the source code of this file.

Typedefs

typedef struct _RaveObjectHashTable_t RaveObjectHashTable_t
 Defines a hash table.
 

Functions

int RaveObjectHashTable_put (RaveObjectHashTable_t *table, const char *key, RaveCoreObject *obj)
 Inserts a key - object binding in the table.
 
RaveCoreObjectRaveObjectHashTable_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.
 
RaveCoreObjectRaveObjectHashTable_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_tRaveObjectHashTable_keys (RaveObjectHashTable_t *table)
 Returns the keys for the table at the current state.
 
RaveObjectList_tRaveObjectHashTable_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.
 

Detailed Description

Implementation of a rave object hashtable that maps between strings and rave core objects.

This object currently does not support RAVE_OBJECT_CLONE.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2010-01-21

Typedef Documentation

◆ RaveObjectHashTable_t

Defines a hash table.

Function Documentation

◆ RaveObjectHashTable_clear()

void RaveObjectHashTable_clear ( RaveObjectHashTable_t * table)

Clears all entries in the table.

Parameters
[in]table- the table

◆ RaveObjectHashTable_destroyKeyList()

void RaveObjectHashTable_destroyKeyList ( RaveList_t * l)

Helper function to destroy the returned list of keys.

Parameters
[in]l- the list to destroy

◆ RaveObjectHashTable_exists()

int RaveObjectHashTable_exists ( RaveObjectHashTable_t * table,
const char * key )

Returns if the specified key exists or not.

Parameters
[in]table- self
[in]key- the key to search for
Returns
1 if the key exists, 0 if it doesn't

◆ RaveObjectHashTable_get()

RaveCoreObject * RaveObjectHashTable_get ( RaveObjectHashTable_t * table,
const char * key )

Returns the object referred to by key.

Parameters
[in]table- the table
[in]key- the key
Returns
the object (or NULL if not found or error)

◆ RaveObjectHashTable_keys()

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.

Parameters
[in]table- self
Returns
a list containing char* pointers.

◆ RaveObjectHashTable_put()

int RaveObjectHashTable_put ( RaveObjectHashTable_t * table,
const char * key,
RaveCoreObject * obj )

Inserts a key - object binding in the table.

Parameters
[in]table- the table
[in]key- the key
[in]obj- the object
Returns
1 on success, otherwise 0

◆ RaveObjectHashTable_remove()

RaveCoreObject * RaveObjectHashTable_remove ( RaveObjectHashTable_t * table,
const char * key )

Removes the item with the specified key and returns it.

Parameters
[in]table- the table
[in]key- the key
Returns
the object (or NULL if none found)

◆ RaveObjectHashTable_size()

int RaveObjectHashTable_size ( RaveObjectHashTable_t * table)

Returns the number of items in this table.

Parameters
[in]table- the table
Returns
the number of items in this table.

◆ RaveObjectHashTable_values()

RaveObjectList_t * RaveObjectHashTable_values ( RaveObjectHashTable_t * table)

Returns the values for the table.

Note, it is not cloned values but references to them.

Parameters
[in]table- self
Returns
a list of values

Variable Documentation

◆ RaveObjectHashTable_TYPE

RaveCoreObjectType RaveObjectHashTable_TYPE
extern

Type definition to use when creating a rave object.