Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
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;
}