static int resize(HHSet *R) { HHSet *S = hhsetnew(2 * R->T->n, R->hash, R->cmp); if (!hhsetcopy(R, S)) { hhsetfree(S); return 0; } HHash *T = R->T; R->T = S->T; S->T = T; hhsetfree(S); return 1; }
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; }
int main(void) { uint n = 256; uint m = 150; HHSet *S = hhmapnew(n,NULL,NULL); fill(S,m); test(m == S->T->m); hhsetfree(S); return 0; }
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; }