bitarray 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/bitarray-array.rb +1 -1
- data/lib/bitarray.rb +3 -3
- data/test/test_bitarray.rb +8 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab9407668ddd315a33ed9cdee09c9fb26e8a7ad5
|
4
|
+
data.tar.gz: a9001387330d54c1285409ad9b6ae95a5c0325cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 944947fd82afbc27f2c2d1266875193fde0058f0409290bdc82b4fc57633749b0d486bcd306710f62b77c89b3f00b1b60b7bcdd99b9f9c67dcacc085e73532e3
|
7
|
+
data.tar.gz: 0b9a68f76af9b1ddcd81a6ea2949ef1a1080923b8977b713aae59982fd325e14b4fdf56025a68aee16744e6c817bd18b7a88b30f17abf9a6a496ca9328304aee
|
data/README.md
CHANGED
@@ -48,6 +48,7 @@ ba.total_set
|
|
48
48
|
```
|
49
49
|
|
50
50
|
## History
|
51
|
+
- 1.1 in 2018 (fixed a significant bug)
|
51
52
|
- 1.0 in 2017 (updated for modern Ruby, more efficient storage, and 10th birthday)
|
52
53
|
- 0.0.1 in 2012 (original v5 released on GitHub)
|
53
54
|
- v5 (added support for flags being on by default, instead of off)
|
@@ -60,6 +61,8 @@ ba.total_set
|
|
60
61
|
|
61
62
|
Thanks to Michael Slade for encouraging me to update this library on its 10th birthday and for suggesting finally using String's getbyte and setbyte methods now that we're all on 1.9+ compatible implementations.
|
62
63
|
|
64
|
+
Further thanks to @tdeo, @JoshuaSP, and @m1lt0n for pull requests.
|
65
|
+
|
63
66
|
## License
|
64
67
|
|
65
|
-
MIT licensed. Copyright 2007-
|
68
|
+
MIT licensed. Copyright 2007-2018 Peter Cooper.
|
data/lib/bitarray-array.rb
CHANGED
data/lib/bitarray.rb
CHANGED
@@ -3,11 +3,11 @@ class BitArray
|
|
3
3
|
attr_reader :field
|
4
4
|
include Enumerable
|
5
5
|
|
6
|
-
VERSION = "1.
|
6
|
+
VERSION = "1.1.0"
|
7
7
|
|
8
8
|
def initialize(size, field = nil)
|
9
9
|
@size = size
|
10
|
-
@field = "\0" * (size / 8 + 1)
|
10
|
+
@field = field || "\0" * (size / 8 + 1)
|
11
11
|
end
|
12
12
|
|
13
13
|
# Set a bit (1/0)
|
@@ -15,7 +15,7 @@ class BitArray
|
|
15
15
|
if value == 1
|
16
16
|
@field.setbyte(position >> 3, @field.getbyte(position >> 3) | (1 << (position % 8)))
|
17
17
|
else
|
18
|
-
@field.setbyte(position >> 3, @field.getbyte(position >> 3)
|
18
|
+
@field.setbyte(position >> 3, @field.getbyte(position >> 3) & ~(1 << (position % 8)))
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/test/test_bitarray.rb
CHANGED
@@ -30,15 +30,19 @@ class TestBitArray < Minitest::Test
|
|
30
30
|
|
31
31
|
def test_multiple_setting
|
32
32
|
1.upto(999) do |pos|
|
33
|
-
2.times
|
34
|
-
|
33
|
+
2.times do
|
34
|
+
@public_ba[pos] = 1
|
35
|
+
assert_equal 1, @public_ba[pos]
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
def test_multiple_unsetting
|
39
41
|
1.upto(999) do |pos|
|
40
|
-
2.times
|
41
|
-
|
42
|
+
2.times do
|
43
|
+
@public_ba[pos] = 0
|
44
|
+
assert_equal 0, @public_ba[pos]
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitarray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Cooper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.6.
|
77
|
+
rubygems_version: 2.6.10
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: A simple, pure Ruby bit-array / bitfield implementation.
|