22 #include <gsl/gsl_rng.h>
23 #include <gsl/gsl_randist.h>
24 #include <gsl/gsl_permutation.h>
25 #include <lal/LALHashTbl.h>
34 elem e = { .
key = key, .value = value };
35 return memcpy(
XLALMalloc(
sizeof( e ) ), &e,
sizeof( e ) );
62 gsl_rng *
r = gsl_rng_alloc( gsl_rng_mt19937 );
64 for (
int n = 0; n < 4; ++n ) {
69 gsl_permutation *
p = gsl_permutation_calloc( 100 );
71 gsl_ran_shuffle(
r,
p->data, 100,
sizeof(
size_t ) );
72 for (
int i = 0; i < 100; ++i ) {
73 int key = 100*n + gsl_permutation_get(
p, i );
77 gsl_permutation_free(
p );
81 for (
int i = 0; i < 100; ++i ) {
82 elem x = { .key = 100*n + i };
90 for (
int i = 0; i < 100; ++i ) {
91 elem x = { .key = 100*n + i };
106 if ( !clear_tested && n == 0 ) {
116 for (
int i = 0; i < 250; ++i ) {
117 elem x = { .key = i };
123 for (
int i = 250; i < 400; ++i ) {
124 elem x = { .key = i };
static void * new_elem(int key, int value)
static UINT8 hash_elem(const void *x)
static int cmp_elem(const void *x, const void *y)
void LALCheckMemoryLeaks(void)
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
LALHashTbl * XLALHashTblCreate(LALHashTblDtorFcn dtor, LALHashTblHashFcn hash, LALHashTblCmpFcn cmp)
Create a hash table.
int XLALHashTblSize(const LALHashTbl *ht)
Return the size of a hash table.
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
int XLALHashTblRemove(LALHashTbl *ht, const void *x)
Find the element matching x in a hash table; if found, remove and destroy it.
void XLALHashTblDestroy(LALHashTbl *ht)
Destroy a hash table and its elements.
int XLALHashTblClear(LALHashTbl *ht)
Clear a hash table.
#define XLAL_CHECK_MAIN(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a C main() routine.
@ XLAL_SUCCESS
Success return value (not an error number)
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
@ XLAL_EFAILED
Generic failure.