summaryrefslogtreecommitdiff
path: root/set_bitsets.c
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2013-12-08 11:22:47 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2013-12-08 11:22:47 +0100
commitbf00b49660fee9b13268fac075a955c8485d4b6b (patch)
treefe71ffa2058a6562d554bafa55656ac1b4ae9462 /set_bitsets.c
parent117cacb7f592bc7a4e506da290fa28dd77530b1a (diff)
downloadAlgoProg-Projet-bf00b49660fee9b13268fac075a955c8485d4b6b.tar.gz
AlgoProg-Projet-bf00b49660fee9b13268fac075a955c8485d4b6b.zip
Correction d'un bug relativement majeur.
Diffstat (limited to 'set_bitsets.c')
-rw-r--r--set_bitsets.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/set_bitsets.c b/set_bitsets.c
index 5578620..bbfd095 100644
--- a/set_bitsets.c
+++ b/set_bitsets.c
@@ -160,14 +160,16 @@ int elt_of_set(const set s){
}
int elt_of_set_heur(const set s, int h){
- int N=nbCells(s.N), i;
+ int N=nbCells(s.N), i, cell;
if(s.tab[h/SCOD]>>(h%SCOD) !=0)
return h + dyadic_val(s.tab[h/SCOD]>>(h%SCOD)) ;
- 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]);
+ for(i=0; i<N; i++) {
+ cell = (i + h/SCOD + 1) % N;
+ if(s.tab[cell] != 0)
+ return cell*SCOD + dyadic_val(s.tab[cell]);
+ }
printf("No element in an empty set!\n");
dump_set(s);