Bug fix
authorbdemsky <bdemsky@uci.edu>
Wed, 20 Sep 2017 20:35:41 +0000 (13:35 -0700)
committerbdemsky <bdemsky@uci.edu>
Wed, 20 Sep 2017 20:35:41 +0000 (13:35 -0700)
src/AST/set.cc

index bd1b3d6..d3801f8 100644 (file)
@@ -40,12 +40,12 @@ bool Set::exists(uint64_t element) {
                        uint middle=(low+high)/2;
                        uint64_t val=members->get(middle);
                        if (element < val) {
                        uint middle=(low+high)/2;
                        uint64_t val=members->get(middle);
                        if (element < val) {
-                               high=middle;
-                               if (middle==low)
+                               high=middle-1;
+                               if (middle<=low)
                                        return false;
                        } else if (element > val) {
                                        return false;
                        } else if (element > val) {
-                               low=middle;
-                               if (middle==high)
+                               low=middle+1;
+                               if (middle>=high)
                                        return false;
                        } else {
                                return true;
                                        return false;
                        } else {
                                return true;