libyasm/hamt.h File Reference

Hash Array Mapped Trie (HAMT) functions. More...

Go to the source code of this file.

Typedefs

typedef HAMT HAMT
 Hash array mapped trie data structure (opaque type).
typedef HAMTEntry HAMTEntry
 Hash array mapped trie entry (opaque type).

Functions

YASM_LIB_DECL HAMTHAMT_create (int nocase, void(*error_func)(const char *file, unsigned int line, const char *message))
 Create new, empty, HAMT.
YASM_LIB_DECL void HAMT_destroy (HAMT *hamt, void(*deletefunc)(void *data))
 Delete HAMT and all data associated with it.
YASM_LIB_DECL void * HAMT_insert (HAMT *hamt, const char *str, void *data, int *replace, void(*deletefunc)(void *data))
 Insert key into HAMT, associating it with data.
YASM_LIB_DECL void * HAMT_search (HAMT *hamt, const char *str)
 Search for the data associated with a key in the HAMT.
YASM_LIB_DECL int HAMT_traverse (HAMT *hamt, void *d, int(*func)(void *node, void *d))
 Traverse over all keys in HAMT, calling function on each data item.
YASM_LIB_DECL const HAMTEntryHAMT_first (const HAMT *hamt)
 Get the first entry in a HAMT.
YASM_LIB_DECL const HAMTEntryHAMT_next (const HAMTEntry *prev)
 Get the next entry in a HAMT.
YASM_LIB_DECL void * HAMTEntry_get_data (const HAMTEntry *entry)
 Get the corresponding data for a HAMT entry.


Detailed Description

Hash Array Mapped Trie (HAMT) functions.

Definition in file hamt.h.


Typedef Documentation

typedef struct HAMT HAMT

Hash array mapped trie data structure (opaque type).

Definition at line 42 of file hamt.h.

typedef struct HAMTEntry HAMTEntry

Hash array mapped trie entry (opaque type).

Definition at line 44 of file hamt.h.


Function Documentation

YASM_LIB_DECL HAMT* HAMT_create ( int  nocase,
void(*)(const char *file, unsigned int line, const char *message)  error_func 
)

Create new, empty, HAMT.

error_func() is called when an internal error is encountered--it should NOT return to the calling function.

Parameters:
nocase nonzero if HAMT should be case-insensitive
error_func function called on internal error
Returns:
New, empty, hash array mapped trie.

YASM_LIB_DECL void HAMT_destroy ( HAMT hamt,
void(*)(void *data)  deletefunc 
)

Delete HAMT and all data associated with it.

Uses deletefunc() to delete each data item.

Parameters:
hamt Hash array mapped trie
deletefunc Data deletion function

YASM_LIB_DECL const HAMTEntry* HAMT_first ( const HAMT hamt  ) 

Get the first entry in a HAMT.

Parameters:
hamt Hash array mapped trie
Returns:
First entry in HAMT, or NULL if HAMT is empty.

YASM_LIB_DECL void* HAMT_insert ( HAMT hamt,
const char *  str,
void *  data,
int *  replace,
void(*)(void *data)  deletefunc 
)

Insert key into HAMT, associating it with data.

If the key is not present in the HAMT, inserts it, sets *replace to 1, and returns the data passed in. If the key is already present and *replace is 0, deletes the data passed in using deletefunc() and returns the data currently associated with the key. If the key is already present and *replace is 1, deletes the data currently associated with the key using deletefunc() and replaces it with the data passed in.

Parameters:
hamt Hash array mapped trie
str Key
data Data to associate with key
replace See above description
deletefunc Data deletion function if data is replaced
Returns:
Data now associated with key.

YASM_LIB_DECL const HAMTEntry* HAMT_next ( const HAMTEntry prev  ) 

Get the next entry in a HAMT.

Parameters:
prev Previous entry in HAMT
Returns:
Next entry in HAMT, or NULL if no more entries.

YASM_LIB_DECL void* HAMT_search ( HAMT hamt,
const char *  str 
)

Search for the data associated with a key in the HAMT.

Parameters:
hamt Hash array mapped trie
str Key
Returns:
NULL if key/data not present in HAMT, otherwise associated data.

YASM_LIB_DECL int HAMT_traverse ( HAMT hamt,
void *  d,
int(*)(void *node, void *d)  func 
)

Traverse over all keys in HAMT, calling function on each data item.

Parameters:
hamt Hash array mapped trie
d Data to pass to each call to func.
func Function to call
Returns:
Stops early (and returns func's return value) if func returns a nonzero value; otherwise 0.

YASM_LIB_DECL void* HAMTEntry_get_data ( const HAMTEntry entry  ) 

Get the corresponding data for a HAMT entry.

Parameters:
entry HAMT entry (as returned by HAMT_first() and HAMT_next())
Returns:
Corresponding data item.


Generated on Thu Jul 24 01:23:31 2008 for libyasm by  doxygen 1.5.2