LAL  7.5.0.1-b72065a
LALHashTbl.c File Reference

Prototypes

static UINT8 hashtbl_no_param_hash (void *param, const void *x)
 
static int hashtbl_no_param_cmp (void *param, const void *x, const void *y)
 
static int hashtbl_resize (LALHashTbl *ht)
 
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...
 

Go to the source code of this file.

Data Structures

struct  LALHashTbl
 Generic hash table with elements of type void * More...
 

Macros

#define DEL   ((void*) &hash_del)
 
#define HASHIDX(ht, x)   ((int)((ht)->hash((ht)->hash_param, (x)) % (ht)->data_len))
 
#define INCRIDX(ht, i)   do { if (++(i) == (ht)->data_len) { (i) = 0; } } while(0)
 
#define EQUAL(ht, x, y)   ((ht)->cmp((ht)->cmp_param, (x), (y)) == 0)
 

Variables

static const void * hash_del = 0
 

Macro Definition Documentation

◆ DEL

#define DEL   ((void*) &hash_del)

Definition at line 24 of file LALHashTbl.c.

◆ HASHIDX

#define HASHIDX (   ht,
 
)    ((int)((ht)->hash((ht)->hash_param, (x)) % (ht)->data_len))

Definition at line 27 of file LALHashTbl.c.

◆ INCRIDX

#define INCRIDX (   ht,
 
)    do { if (++(i) == (ht)->data_len) { (i) = 0; } } while(0)

Definition at line 30 of file LALHashTbl.c.

◆ EQUAL

#define EQUAL (   ht,
  x,
 
)    ((ht)->cmp((ht)->cmp_param, (x), (y)) == 0)

Definition at line 33 of file LALHashTbl.c.

Function Documentation

◆ hashtbl_no_param_hash()

static UINT8 hashtbl_no_param_hash ( void *  param,
const void *  x 
)
static

Definition at line 48 of file LALHashTbl.c.

◆ hashtbl_no_param_cmp()

static int hashtbl_no_param_cmp ( void *  param,
const void *  x,
const void *  y 
)
static

Definition at line 55 of file LALHashTbl.c.

◆ hashtbl_resize()

static int hashtbl_resize ( LALHashTbl *  ht)
static

Definition at line 62 of file LALHashTbl.c.

Variable Documentation

◆ hash_del

const void* hash_del = 0
static

Definition at line 23 of file LALHashTbl.c.