22#include <lal/LALBitset.h>
23#include <lal/LALHashTbl.h>
25#define BITS_PER_ELEM (sizeof(UINT8) * CHAR_BIT)
57 LALBitset *bs =
XLALCalloc( 1,
sizeof( *bs ) );
108 const elem x = { .key = key };
119 y->bits |= ( ( (
UINT8) 1 ) << bitidx );
121 y->bits &= ~( ( (
UINT8) 1 ) << bitidx );
147 const elem x = { .key = key };
148 const elem *
y = NULL;
155 *is_set = (
y->bits & ( ( (
UINT8) 1 ) << bitidx ) ) ? 1 : 0;
static UINT8 hash_elem(const void *x)
static int cmp_elem(const void *x, const void *y)
LALBitset * XLALBitsetCreate(void)
Create a bitset.
int XLALBitsetClear(LALBitset *bs)
Clear a bitset.
void XLALBitsetDestroy(LALBitset *bs)
Destroy a bitset and its elements.
int XLALBitsetGet(const LALBitset *bs, const UINT8 idx, BOOLEAN *is_set)
Get whether a bit in the bitset is set.
int XLALBitsetSet(LALBitset *bs, const UINT8 idx, const BOOLEAN is_set)
Set/unset a bit in the bitset.
unsigned char BOOLEAN
Boolean logical type, see Headers LAL(Atomic)Datatypes.h for more details.
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
uint16_t UINT2
Two-byte unsigned integer.
int XLALPearsonHash(void *hval, const size_t hval_len, const void *data, const size_t data_len)
Compute a arbitrary-sized Pearson hash value for the given arbitrary data.
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
int XLALHashTblAdd(LALHashTbl *ht, void *x)
Add an element to a hash table.
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
LALHashTbl * XLALHashTblCreate(LALHashTblDtorFcn dtor, LALHashTblHashFcn hash, LALHashTblCmpFcn cmp)
Create a hash table.
void XLALHashTblDestroy(LALHashTbl *ht)
Destroy a hash table and its elements.
int XLALHashTblClear(LALHashTbl *ht)
Clear a hash table.
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
#define XLAL_CHECK_NULL(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns a pointe...
@ XLAL_ENOMEM
Memory allocation error.
@ XLAL_SUCCESS
Success return value (not an error number)
@ XLAL_EFAULT
Invalid pointer.
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.