lib/bx.rb in bx-0.1.0 vs lib/bx.rb in bx-0.1.1
- old
+ new
@@ -1,10 +1,10 @@
require "bx/version"
class Bx
class ::Integer
- def highest_one_bits
+ def hi_bits
int = self
Enumerator.new do |e|
loop do
b_len = int.bit_length
break if b_len == 0
@@ -13,11 +13,11 @@
int = int ^ (1 << pos)
end
end
end
- def lowest_one_bits
+ def lo_bits
int = self
Enumerator.new do |e|
off = 0
loop do
lowest = int & -int
@@ -39,7 +39,19 @@
@hash[key] |= (1 << id)
end
def [](key)
@hash[key]
+ end
+
+ def keys
+ @hash.keys
+ end
+
+ def values
+ @hash.values
+ end
+
+ def bits_bytes
+ @hash.each_value.sum(&:size)
end
end