File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -46,10 +46,10 @@ commonPrefix t =
46
46
case t of
47
47
Nil -> True
48
48
Tip _ _ -> True
49
- b@ (Bin p _ _ _ ) -> all (sharedPrefix p) (keys b)
49
+ b@ (Bin p _ l r ) -> all (sharedPrefix p) (keys b) && commonPrefix l && commonPrefix r
50
50
where
51
51
sharedPrefix :: Prefix -> Int -> Bool
52
- sharedPrefix p a = 0 == (p `xor` (p .&. a))
52
+ sharedPrefix p a = p == p .&. a
53
53
54
54
-- Invariant: In Bin prefix mask left right, left consists of the elements that
55
55
-- don't have the mask bit set; right is all the elements that do.
@@ -60,4 +60,6 @@ maskRespected t =
60
60
Tip _ _ -> True
61
61
Bin _ binMask l r ->
62
62
all (\ x -> zero x binMask) (keys l) &&
63
- all (\ x -> not (zero x binMask)) (keys r)
63
+ all (\ x -> not (zero x binMask)) (keys r) &&
64
+ maskRespected l &&
65
+ maskRespected r
Original file line number Diff line number Diff line change @@ -49,10 +49,10 @@ commonPrefix t =
49
49
case t of
50
50
Nil -> True
51
51
Tip _ _ -> True
52
- b@ (Bin p _ _ _ ) -> all (sharedPrefix p) (elems b)
52
+ b@ (Bin p _ l r ) -> all (sharedPrefix p) (elems b) && commonPrefix l && commonPrefix r
53
53
where
54
54
sharedPrefix :: Prefix -> Int -> Bool
55
- sharedPrefix p a = 0 == (p `xor` (p .&. a))
55
+ sharedPrefix p a = p == p .&. a
56
56
57
57
-- Invariant: In Bin prefix mask left right, left consists of the elements that
58
58
-- don't have the mask bit set; right is all the elements that do.
@@ -63,7 +63,9 @@ maskRespected t =
63
63
Tip _ _ -> True
64
64
Bin _ binMask l r ->
65
65
all (\ x -> zero x binMask) (elems l) &&
66
- all (\ x -> not (zero x binMask)) (elems r)
66
+ all (\ x -> not (zero x binMask)) (elems r) &&
67
+ maskRespected l &&
68
+ maskRespected r
67
69
68
70
-- Invariant: The Prefix is zero for the last 5 (on 32 bit arches) or 6 bits
69
71
-- (on 64 bit arches). The values of the set represented by a tip
You can’t perform that action at this time.
0 commit comments