Exemplo n.º 1
0
HHSet *hhsetnew(ulong n, ulong (*hash)(ulong), int (*cmp)(ulong, ulong)) {
  HHSet *S = malloc(sizeof(HHSet));
  S->T = hhashnew(n);
  S->hash = (hash != NULL) ? hash : iid;
  S->cmp = (cmp != NULL) ? cmp : neqq;
  return S;
}
Exemplo n.º 2
0
int main(void) {
  ulong n = 256;
  HHash *T = hhashnew(n);
  ulong m = fill(T);
  test(m == T->m);
  test(m == count(T));
  hhashfree(T);
  return 0;
}
Exemplo n.º 3
0
int
main(void)
{
	uint n = 16;
	HHash *T = hhashnew(n);
	uint x = rand()%n;
	test(hhashput(T,x,1));
	uint i = hhashsucc(T,x,0);
	test(i == 0);
	hhashdel(T,x,i);
	test(hhashsucc(T,x,0) < 0);
	hhashfree(T);
	return 0;
}
Exemplo n.º 4
0
int
main(void)
{
	uint n = 16;
	HHash *T = hhashnew(n);
	uint x = 15;
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,0) == 0);
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,1) == 1);
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,2) == 2);
	test(T->m == 3);
	x = 14;
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,0) == 0);
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,1) == 1);
	test(!hhashput(T,x,1));
	hhashfree(T);
	return 0;
}
Exemplo n.º 5
0
int
main(void)
{
	uint n = 16;
	HHash *T = hhashnew(n);
	uint x = rand()%n;
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,0) == 0);
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,1) == 1);
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,2) == 2);
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,3) == 3);
	test(!hhashput(T,x,1));
	--x;
	test(hhashput(T,x,1));
	test(hhashsucc(T,x,0) == 0);
	test(!hhashput(T,x,1));
	hhashfree(T);
	return 0;
}