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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c79a60a3580af853940651ca520abd24f359fc97
4
- data.tar.gz: 96cb2ffe5551ac793e33f3eb06563aadcc6cfd1d
3
+ metadata.gz: ab9407668ddd315a33ed9cdee09c9fb26e8a7ad5
4
+ data.tar.gz: a9001387330d54c1285409ad9b6ae95a5c0325cc
5
5
  SHA512:
6
- metadata.gz: bcd93a192a22cf477b45cd582028a3cd60c090dd9cdfbfd5b507a86f4c996a1dede387926d34f0495441cb90b0d899c96d5bb9a34dc8b16b5e933794f0e89bf1
7
- data.tar.gz: cb2b120ce2abe9242bfc07ac9f1dff0bff7aab271daabaaafca53f39a06be8ce690946575bc6c423e8258fbf99c284ab783301327c0495bb37477798a0def376
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-2017 Peter Cooper.
68
+ MIT licensed. Copyright 2007-2018 Peter Cooper.
@@ -3,7 +3,7 @@ class BitArray
3
3
  attr_reader :field
4
4
  include Enumerable
5
5
 
6
- VERSION = "1.0.0"
6
+ VERSION = "1.1.0"
7
7
  ELEMENT_WIDTH = 32
8
8
 
9
9
  def initialize(size, field = nil)
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.0.0"
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) ^ (1 << (position % 8)))
18
+ @field.setbyte(position >> 3, @field.getbyte(position >> 3) & ~(1 << (position % 8)))
19
19
  end
20
20
  end
21
21
 
@@ -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 { @public_ba[pos] = 1 }
34
- assert_equal 1, @public_ba[pos]
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 { @public_ba[pos] = 0 }
41
- assert_equal 0, @public_ba[pos]
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.0.0
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: 2017-01-07 00:00:00.000000000 Z
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.8
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.