xor_reverse_bitswap 0.1.0 → 0.2.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
  SHA256:
3
- metadata.gz: d1f93033512a439e8fb22494b9142a0cebb1a0a01e1b98a77663d88b86ad9210
4
- data.tar.gz: 385dc2881b5e581e456e44351c4a85858ae53702e32531c996087fe391599c0f
3
+ metadata.gz: 3e211abcb0ee65f3130fb82ac8a6ae4c603f4c49a3ebae1e8a92ef6dd82756a4
4
+ data.tar.gz: 819d8db4fa89522d4a5e3876a2e4e6c26b1fe33568852720b8cafd06c8d2c3b6
5
5
  SHA512:
6
- metadata.gz: 5b7aaa5d691f45fe01096d576795f423892b1c6949a9060ab16470b693a6f5c0d7f997fee31805f814af648e3942236b60d3bcacb2ef30fbe19d8b4c8b90d427
7
- data.tar.gz: f4127f207273af8a9d020e07c3138510bb41f0eed44303de3fed27d44d91280557b671f713d9db155ed3e13a5214f0baab358b9882ca2c7ab6c73513f3e94639
6
+ metadata.gz: 28c0efb07aea2b2c42de8409ae16a05a0fe28635b01a768de611ee92b2cc9ddf3a4a741b19cfe25f0962a073520e0f7e8a8f12bd1eca156d3c54d2bce87e69a1
7
+ data.tar.gz: aa0b92b17a46db6f65d15dc0ec642288218868314be8348683532fd6f02c887b7dd6404a5a000beebfbed4e6438833f8d7e8017ba5a4bbe045602c12f9e58508
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xor_reverse_bitswap (0.1.0)
4
+ xor_reverse_bitswap (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XorReverseBitswap
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -21,17 +21,30 @@ module XorReverseBitswap
21
21
 
22
22
  def self.ranger(start_range:, end_range:, step_size: 1)
23
23
  range_size = (end_range - start_range) / step_size
24
- offset = (end_range - start_range)
25
24
  raise "range_size must be full 1s binary" unless range_size.to_s(2).count("0").zero?
26
25
 
27
26
  bit_range_size = range_size.to_s(2).size
28
- (1..range_size).map do |n|
29
- value = (n ^ range_size).to_s(2).rjust(bit_range_size, "0").reverse.to_i(2)
30
- Range.new(
31
- offset + (value * step_size),
32
- offset + ((value + 1) * step_size)
33
- ).tap do |r|
34
- raise "range #{r} is out of bounds" unless (start_range..end_range).cover?(r)
27
+ if step_size > 1
28
+ (0..range_size).map do |n|
29
+ value = (n ^ range_size).to_s(2).rjust(bit_range_size, "0").reverse.to_i(2)
30
+ [
31
+ start_range + (value * step_size),
32
+ start_range + ((value + 1) * step_size) - 1
33
+ ].tap do |r1, r2|
34
+ raise "range #{r1} is out of bounds" unless (start_range..end_range).cover?(r1)
35
+ raise "range #{r2} is out of bounds" unless (start_range..end_range).cover?(r2)
36
+ end
37
+ end
38
+ else
39
+ (1..range_size).map do |n|
40
+ value = (n ^ range_size).to_s(2).rjust(bit_range_size, "0").reverse.to_i(2)
41
+ [
42
+ start_range + (value * step_size),
43
+ start_range + ((value + 1) * step_size)
44
+ ].tap do |r1, r2|
45
+ raise "range #{r1} is out of bounds" unless (start_range..end_range).cover?(r1)
46
+ raise "range #{r2} is out of bounds" unless (start_range..end_range).cover?(r2)
47
+ end
35
48
  end
36
49
  end
37
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xor_reverse_bitswap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patryk Ptasinski