int main(void) { ulong n = 256; srand(13948824); HHSet *S = hhsetnew(n, NULL, NULL); x = rand(); hhsetput(S, x); fill(S); hhsetfree(S); return 0; }
static ulong fill(HHSet *S) { ulong m = 0; for (ulong i = 0; i < 128; ++i) { ulong y = rand() + 1; if (!hhsetget(S, y)) { test(hhsetput(S, y)); ++m; } test(hhsetget(S, x)); } return m; }
static uint fill(HHSet *S) { uint m = 0; for(uint i = 0; i < 128; ++i){ uint y = rand()+1; if(!hhsetget(S,y)){ test(hhsetput(S,y)); ++m; } test(hhsetget(S,x)); } return m; }
int main(void) { uint n = 16; uint m = 0; HHSet *S = hhsetnew(n,NULL,NULL); for(uint i = 0; i < 30; ++i){ uint x = rand()+1; if(!hhsetget(S,x)){ test(hhsetput(S,x)); ++m; } } test(S->T->m == m); hhsetfree(S); return 0; }
int hhmapput(HHSet *S, uint k, uint v) { if (v == 0) return 0; ulong x = (((ulong)v) << HALF) | k; return hhsetput(S, x); }