hyperll 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hyperll/register_set.rb +4 -3
- data/lib/hyperll/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 641d27a87b64d8c4f0f00519c6936b2276b1ca43
|
4
|
+
data.tar.gz: 18fab0477ccba2f4e27ce9009d910339bc51c53a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2d542b9b698fe943f48e83f0968c4cb66dda818170f0c2851a5746decca94252aa4b5c6103527f9411df929417ae583723ed648d96d119aa05250e200e1f9b7
|
7
|
+
data.tar.gz: d233ae38368376bc3dfdc8b49e7dea8aced87665eab2dd700338e24484a53c26eeb34bc136825210441a0244ec8fba9a6fd3cc31d6f785ea1ce8760310393ea6
|
data/lib/hyperll/register_set.rb
CHANGED
@@ -5,6 +5,7 @@ module Hyperll
|
|
5
5
|
LOG2_BITS_PER_WORD = 6
|
6
6
|
REGISTER_SIZE = 5
|
7
7
|
INTEGER_SIZE = 32
|
8
|
+
INT_MASK = 0xFFFFFFFF
|
8
9
|
|
9
10
|
attr_reader :count, :size
|
10
11
|
|
@@ -27,7 +28,7 @@ module Hyperll
|
|
27
28
|
bucket = position / LOG2_BITS_PER_WORD
|
28
29
|
shift = REGISTER_SIZE * (position - (bucket * LOG2_BITS_PER_WORD))
|
29
30
|
|
30
|
-
@values[bucket] = (@values[bucket] & ~(0x1f << shift)) | (value << shift)
|
31
|
+
@values[bucket] = ((@values[bucket] & ~(0x1f << shift)) | (value << shift)) & INT_MASK
|
31
32
|
end
|
32
33
|
|
33
34
|
def [](position)
|
@@ -47,12 +48,12 @@ module Hyperll
|
|
47
48
|
def update_if_greater(position, value)
|
48
49
|
bucket = position / LOG2_BITS_PER_WORD
|
49
50
|
shift = REGISTER_SIZE * (position - (bucket * LOG2_BITS_PER_WORD));
|
50
|
-
mask = 0x1f << shift
|
51
|
+
mask = (0x1f << shift) & INT_MASK
|
51
52
|
|
52
53
|
current_value = @values[bucket] & mask
|
53
54
|
new_value = value << shift
|
54
55
|
if current_value < new_value
|
55
|
-
@values[bucket] = (@values[bucket] & ~mask) | new_value
|
56
|
+
@values[bucket] = ((@values[bucket] & ~mask) | new_value) & INT_MASK
|
56
57
|
true
|
57
58
|
else
|
58
59
|
false
|
data/lib/hyperll/version.rb
CHANGED