diff options
author | Alex Auvolat--bernstein <auvolat@clipper.ens.fr> | 2013-12-04 16:49:43 +0100 |
---|---|---|
committer | Alex Auvolat--bernstein <auvolat@clipper.ens.fr> | 2013-12-04 16:49:43 +0100 |
commit | 000a92524d2165daf7c790705fea91358b6ecf15 (patch) | |
tree | 6583304cc8f62347994288772d3c3d881839e3c9 | |
parent | cbec036a66960eea2ff1f1cda1f1e07f39461eb9 (diff) | |
parent | 78bac8d58b3ed8d5cdb575c6e3ebd99773e5b336 (diff) | |
download | AlgoProg-Projet-000a92524d2165daf7c790705fea91358b6ecf15.tar.gz AlgoProg-Projet-000a92524d2165daf7c790705fea91358b6ecf15.zip |
Merge branch 'master' of /users/13/info/oulamara/Work/AlgoProg-Projet
-rw-r--r-- | set_bitsets.c | 15 | ||||
-rw-r--r-- | set_linked_lists.c | 4 | ||||
-rw-r--r-- | sets.h | 1 |
3 files changed, 20 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)){ diff --git a/set_linked_lists.c b/set_linked_lists.c index ee0a021..86a53b3 100644 --- a/set_linked_lists.c +++ b/set_linked_lists.c @@ -242,6 +242,10 @@ int elt_of_set(const set s) { return -1; // should raise exception... hope this will be handled properly } +int elt_of_set_heur(const set s, int h) { + return elt_of_set(s); +} + void set_add_ip(int x, set s) { element prev, iter, e; @@ -60,6 +60,7 @@ bool set_mem(int x, const set s); bool sets_equal(const set a, const set b); int elt_of_set(const set s); +int elt_of_set_heur(const set s, int h); set set_add(int x, const set s); void set_add_ip(int x, set s); |