LAL  7.5.0.1-b72065a

Detailed Description

Implementation of a generic hash table, following Chapter 5.2 of [19] .

Author
Karl Wette

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...
 

Function Documentation

◆ XLALHashTblCreate()

LALHashTbl* XLALHashTblCreate ( LALHashTblDtorFcn  dtor,
LALHashTblHashFcn  hash,
LALHashTblCmpFcn  cmp 
)

Create a hash table.

Parameters
[in]dtorFunction to free memory of elements of hash, if required
[in]hashHash function for hash table elements
[in]cmpHash table element comparison function

Definition at line 86 of file LALHashTbl.c.

◆ XLALHashTblCreate2()

LALHashTbl* XLALHashTblCreate2 ( LALHashTblDtorFcn  dtor,
LALHashTblHashParamFcn  hash,
void *  hash_param,
LALHashTblCmpParamFcn  cmp,
void *  cmp_param 
)

Create a hash table with parameterised hash and comparison functions.

Parameters
[in]dtorFunction to free memory of elements of hash, if required
[in]hashParameterised hash function for hash table elements
[in]hash_paramParameter to pass to hash function
[in]cmpParameterised hash table element comparison function
[in]cmp_paramParameter to pass to comparison function

Definition at line 101 of file LALHashTbl.c.

◆ XLALHashTblDestroy()

void XLALHashTblDestroy ( LALHashTbl *  ht)

Destroy a hash table and its elements.

Parameters
[in]htPointer to hash table

Definition at line 129 of file LALHashTbl.c.

◆ XLALHashTblClear()

int XLALHashTblClear ( LALHashTbl *  ht)

Clear a hash table.

Parameters
[in]htPointer to hash table

Definition at line 148 of file LALHashTbl.c.

◆ XLALHashTblSize()

int XLALHashTblSize ( const LALHashTbl *  ht)

Return the size of a hash table.

Parameters
[in]htPointer to hash table

Definition at line 177 of file LALHashTbl.c.

◆ XLALHashTblFind()

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

Parameters
[in]htPointer to hash table
[in]xHash element to match
[out]yPointer to matched hash element, or NULL if not found

Definition at line 185 of file LALHashTbl.c.

◆ XLALHashTblAdd()

int XLALHashTblAdd ( LALHashTbl *  ht,
void *  x 
)

Add an element to a hash table.

Parameters
[in]htPointer to hash table
[in]xHash element to add

Definition at line 215 of file LALHashTbl.c.

◆ XLALHashTblExtract()

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

Parameters
[in]htPointer to hash table
[in]xHash element to match
[out]yPointer 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.

◆ XLALHashTblRemove()

int XLALHashTblRemove ( LALHashTbl *  ht,
const void *  x 
)

Find the element matching x in a hash table; if found, remove and destroy it.

Parameters
[in]htPointer to hash table
[in]xHash element to match

Definition at line 287 of file LALHashTbl.c.

Typedef Documentation

◆ LALHashTblDtorFcn

typedef void( * LALHashTblDtorFcn) (void *x)

Function which free memory associated with hash table element x

Definition at line 46 of file LALHashTbl.h.

◆ LALHashTblHashFcn

typedef UINT8( * LALHashTblHashFcn) (const void *x)

Hash function for the hash table element x

Definition at line 51 of file LALHashTbl.h.

◆ LALHashTblHashParamFcn

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.

◆ LALHashTblCmpFcn

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.

◆ LALHashTblCmpParamFcn

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.