Skip to content
Browse files

Store a mask rather than the bit in the tree.

  • Loading branch information...
1 parent f8b9682 commit 37602f7988f26ea5295d12bd49f7c0d25d43b1c0 @jlouis committed Feb 17, 2011
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/patricia.erl
View
12 src/patricia.erl
@@ -49,17 +49,16 @@ crit_bit(I1, I2, N) ->
0 ->
crit_bit(I1, I2, N-1);
_ ->
- {N, cmp_lt_bit(I1, I2, N)}
+ {Bit, cmp_lt_bit(I1, I2, Bit)}
end.
-spec cmp_lt_bit(integer(), integer(), pos_integer()) -> boolean().
-cmp_lt_bit(I1, I2, N) ->
- Bit = (1 bsl N),
+cmp_lt_bit(I1, I2, Bit) ->
(Bit band I1) < (Bit band I2).
inspect_bit(H, Bit) ->
- case H band (1 bsl Bit) of
+ case H band Bit of
0 -> left;
_ -> right
end.
@@ -112,3 +111,8 @@ is_element(Key, {node, Bit, L, R}, H) ->
+
+
+
+
+

0 comments on commit 37602f7

Please sign in to comment.
Something went wrong with that request. Please try again.