diff options
author | Mendes Oulamara <oulamara@clipper.ens.fr> | 2013-12-04 16:47:33 +0100 |
---|---|---|
committer | Mendes Oulamara <oulamara@clipper.ens.fr> | 2013-12-04 16:47:33 +0100 |
commit | 13d3fd69bc37eb35ccbb6122522c7848a7234245 (patch) | |
tree | 88a123a7beb124d0b83f147cf30ea6a8559f943d /set_bitsets.c | |
parent | 77db931b94870a8f28eef482091924471cd18d64 (diff) | |
download | AlgoProg-Projet-13d3fd69bc37eb35ccbb6122522c7848a7234245.tar.gz AlgoProg-Projet-13d3fd69bc37eb35ccbb6122522c7848a7234245.zip |
Add heuritic to bitsets
Diffstat (limited to 'set_bitsets.c')
-rw-r--r-- | set_bitsets.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/set_bitsets.c b/set_bitsets.c index 30e4dc9..53af83a 100644 --- a/set_bitsets.c +++ b/set_bitsets.c @@ -129,6 +129,21 @@ int elt_of_set(const set s){ assert(false); } +int elt_of_set_heur(const set s, int h){ + int N=nbCells(s.N), i; + + if(s.tab[h/SCOD]>>(h%SCOD+1) !=0) + return h + dyadic_val(s.tab[h/SCOD]>>(h%SCOD+1)) + 1; + + for(i=0; i<N; i++) + if(s.tab[(i+h/SCOD+1)%N] != 0) + return i*SCOD+dyadic_val(s.tab[(i+h/SCOD+1)%N]); + + printf("No element in an empty set!\n"); + dump_set(s); + assert(false); +} + void set_add_ip(int x, set s){ unsigned long long ux = x; if(! set_mem(ux, s)){ |