summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--set_bitsets.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index b81992e..d61ac57 100644
--- a/Makefile
+++ b/Makefile
@@ -4,13 +4,13 @@ COMMON_H=graph.h sets.h algos.h
all : exe_ll exe_bs exe_tr exe_ll_test
exe_ll : set_linked_lists.c $(COMMON_C) $(COMMON_H)
- gcc -o exe_ll set_linked_lists.c $(COMMON_C) -DLINKEDLISTS -g -O2
+ gcc -o exe_ll set_linked_lists.c $(COMMON_C) -DLINKEDLISTS -g -O3
exe_ll_test : set_test.c sets.h set_linked_lists.c sets.c
gcc -o exe_ll_test set_test.c set_linked_lists.c sets.c -DLINKEDLISTS -g
exe_bs : set_bitsets.c $(COMMON_C) $(COMMON_H)
- gcc -o exe_bs set_bitsets.c $(COMMON_C) -DBITSETS -g
+ gcc -o exe_bs set_bitsets.c $(COMMON_C) -DBITSETS -g -O3
exe_bs_test : set_test.c sets.h set_bitsets.c sets.c
gcc -o exe_ll_test set_test.c set_bitsets.c sets.c graphc. -DBITSETS -g
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);