Implementation of a generic hash table, following Chapter 5.2 of [19] .
Prototypes | |
LALHashTbl * | XLALHashTblCreate (LALHashTblDtorFcn dtor, LALHashTblHashFcn hash, LALHashTblCmpFcn cmp) |
Create a hash table. More... | |
LALHashTbl * | XLALHashTblCreate2 (LALHashTblDtorFcn dtor, LALHashTblHashParamFcn hash, void *hash_param, LALHashTblCmpParamFcn cmp, void *cmp_param) |
Create a hash table with parameterised hash and comparison functions. More... | |
void | XLALHashTblDestroy (LALHashTbl *ht) |
Destroy a hash table and its elements. More... | |
int | XLALHashTblClear (LALHashTbl *ht) |
Clear a hash table. More... | |
int | XLALHashTblSize (const LALHashTbl *ht) |
Return the size of a hash table. More... | |
int | XLALHashTblFind (const LALHashTbl *ht, const void *x, const void **y) |
Find the element matching x in a hash table; if found, return in *y More... | |
int | XLALHashTblAdd (LALHashTbl *ht, void *x) |
Add an element to a hash table. More... | |
int | XLALHashTblExtract (LALHashTbl *ht, const void *x, void **y) |
Find the element matching x in a hash table; if found, remove it and return in *y More... | |
int | XLALHashTblRemove (LALHashTbl *ht, const void *x) |
Find the element matching x in a hash table; if found, remove and destroy it. More... | |
Typedefs | |
typedef void(* | LALHashTblDtorFcn) (void *x) |
Function which free memory associated with hash table element x More... | |
typedef UINT8(* | LALHashTblHashFcn) (const void *x) |
Hash function for the hash table element x More... | |
typedef UINT8(* | LALHashTblHashParamFcn) (void *param, const void *x) |
Hash function for the hash table element x , with a parameter param . More... | |
typedef int(* | LALHashTblCmpFcn) (const void *x, const void *y) |
Function which compares hash table elements x and y More... | |
typedef int(* | LALHashTblCmpParamFcn) (void *param, const void *x, const void *y) |
Function which compares hash table elements x and y , with a parameter param . More... | |
LALHashTbl* XLALHashTblCreate | ( | LALHashTblDtorFcn | dtor, |
LALHashTblHashFcn | hash, | ||
LALHashTblCmpFcn | cmp | ||
) |
Create a hash table.
[in] | dtor | Function to free memory of elements of hash, if required |
[in] | hash | Hash function for hash table elements |
[in] | cmp | Hash table element comparison function |
Definition at line 86 of file LALHashTbl.c.
LALHashTbl* XLALHashTblCreate2 | ( | LALHashTblDtorFcn | dtor, |
LALHashTblHashParamFcn | hash, | ||
void * | hash_param, | ||
LALHashTblCmpParamFcn | cmp, | ||
void * | cmp_param | ||
) |
Create a hash table with parameterised hash and comparison functions.
[in] | dtor | Function to free memory of elements of hash, if required |
[in] | hash | Parameterised hash function for hash table elements |
[in] | hash_param | Parameter to pass to hash function |
[in] | cmp | Parameterised hash table element comparison function |
[in] | cmp_param | Parameter to pass to comparison function |
Definition at line 101 of file LALHashTbl.c.
void XLALHashTblDestroy | ( | LALHashTbl * | ht | ) |
Destroy a hash table and its elements.
[in] | ht | Pointer to hash table |
Definition at line 129 of file LALHashTbl.c.
int XLALHashTblClear | ( | LALHashTbl * | ht | ) |
Clear a hash table.
[in] | ht | Pointer to hash table |
Definition at line 148 of file LALHashTbl.c.
int XLALHashTblSize | ( | const LALHashTbl * | ht | ) |
Return the size of a hash table.
[in] | ht | Pointer to hash table |
Definition at line 177 of file LALHashTbl.c.
int XLALHashTblFind | ( | const LALHashTbl * | ht, |
const void * | x, | ||
const void ** | y | ||
) |
Find the element matching x
in a hash table; if found, return in *y
[in] | ht | Pointer to hash table |
[in] | x | Hash element to match |
[out] | y | Pointer to matched hash element, or NULL if not found |
Definition at line 185 of file LALHashTbl.c.
int XLALHashTblAdd | ( | LALHashTbl * | ht, |
void * | x | ||
) |
Add an element to a hash table.
[in] | ht | Pointer to hash table |
[in] | x | Hash element to add |
Definition at line 215 of file LALHashTbl.c.
int XLALHashTblExtract | ( | LALHashTbl * | ht, |
const void * | x, | ||
void ** | y | ||
) |
Find the element matching x
in a hash table; if found, remove it and return in *y
[in] | ht | Pointer to hash table |
[in] | x | Hash element to match |
[out] | y | Pointer to matched hash element, which has been removed from the hash table, or NULL if not found |
Definition at line 252 of file LALHashTbl.c.
int XLALHashTblRemove | ( | LALHashTbl * | ht, |
const void * | x | ||
) |
Find the element matching x
in a hash table; if found, remove and destroy it.
[in] | ht | Pointer to hash table |
[in] | x | Hash element to match |
Definition at line 287 of file LALHashTbl.c.
typedef void( * LALHashTblDtorFcn) (void *x) |
Function which free memory associated with hash table element x
Definition at line 46 of file LALHashTbl.h.
typedef UINT8( * LALHashTblHashFcn) (const void *x) |
Hash function for the hash table element x
Definition at line 51 of file LALHashTbl.h.
typedef UINT8( * LALHashTblHashParamFcn) (void *param, const void *x) |
Hash function for the hash table element x
, with a parameter param
.
Definition at line 56 of file LALHashTbl.h.
typedef int( * LALHashTblCmpFcn) (const void *x, const void *y) |
Function which compares hash table elements x
and y
Definition at line 61 of file LALHashTbl.h.
typedef int( * LALHashTblCmpParamFcn) (void *param, const void *x, const void *y) |
Function which compares hash table elements x
and y
, with a parameter param
.
Definition at line 66 of file LALHashTbl.h.