hashmap.h File Reference

Contains the interface specification of a hashmap. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define HASHMAP_ILLEGAL   0
 Flags an illegal access.
#define HASHMAP_INSERT   1
 New element inserted - flag.
#define HASHMAP_UPDATE   2
 Update of existing element.

Typedefs

typedef void(* fHashmapProc )(const char *key, const void *datum)
 Prototype of a function that processes an item.

Functions

hashmap * newHashmap (unsigned int hint)
 Creates a new hashmap.
void deleteHashmap (hashmap *map)
 Destroys the hashmap without touching saved data.
int hashmapSet (hashmap *map, void *data, const char *key)
 Inserts a new element into the map or updates an existing one.
void * hashmapGet (const hashmap *map, const char *key)
 Returns the element associated with a given key.
void * hashmapRemove (hashmap *map, const char *key)
 Removes the element associated with a given key from the map and returns it.
void hashmapProcess (const hashmap *map, fHashmapProc proc)
 Processes all elements of the map in lexicographical order of their keys.


Detailed Description

Contains the interface specification of a hashmap.

Author:
Dorian Weber
See also:
hashmap.c

Definition in file hashmap.h.


Define Documentation

#define HASHMAP_ILLEGAL   0

Flags an illegal access.

Definition at line 14 of file hashmap.h.

#define HASHMAP_INSERT   1

New element inserted - flag.

Definition at line 15 of file hashmap.h.

#define HASHMAP_UPDATE   2

Update of existing element.

Definition at line 16 of file hashmap.h.


Typedef Documentation

typedef void(* fHashmapProc)(const char *key, const void *datum)

Prototype of a function that processes an item.

Parameters:
[in] key the key
[in] datum the associated datum

Definition at line 22 of file hashmap.h.


Function Documentation

void deleteHashmap ( hashmap *  map  ) 

Destroys the hashmap without touching saved data.

Parameters:
[in] map target hashmap

Definition at line 234 of file hashmap.c.

void* hashmapGet ( const hashmap *  map,
const char *  key 
)

Returns the element associated with a given key.

Parameters:
[in] map target hashmap
[in] key the key
Returns:
the element associated with a key, if existing,
NULL otherwise

Definition at line 257 of file hashmap.c.

void hashmapProcess ( const hashmap *  map,
fHashmapProc  proc 
)

Processes all elements of the map in lexicographical order of their keys.

Precondition:
proc is not NULL
Parameters:
[in] map target hashmap
[in] proc function that processes an item

Definition at line 294 of file hashmap.c.

void* hashmapRemove ( hashmap *  map,
const char *  key 
)

Removes the element associated with a given key from the map and returns it.

Parameters:
[in] map target hashmap
[in] key the key
Returns:
the element associated with a key, if existing,
NULL otherwise

Definition at line 270 of file hashmap.c.

int hashmapSet ( hashmap *  map,
void *  data,
const char *  key 
)

Inserts a new element into the map or updates an existing one.

Precondition:
key is not NULL or empty.
Parameters:
[in] map target hashmap
[in] data pointer to the data
[in] key the key
Returns:
HASHMAP_ILLEGAL, if the key is invalid (NULL or empty)
HASHMAP_INSERT, if the element was inserted
HASHMAP_UPDATE, if the element got updated (overwritten)

Definition at line 251 of file hashmap.c.

hashmap* newHashmap ( unsigned int  hint  ) 

Creates a new hashmap.

Note:
The hashmap resizes itself automatically.
Parameters:
[in] hint indicates the estimated number of entries
Returns:
pointer to a hashmap

Definition at line 206 of file hashmap.c.


Generated on Fri Jun 5 15:31:57 2009 for DeadStrip Utility by  doxygen 1.5.8