Module: Lrama::Bitmap
- Defined in:
- lib/lrama/bitmap.rb
Class Method Summary collapse
Class Method Details
.from_array(ary) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/lrama/bitmap.rb', line 7 def self.from_array(ary) bit = 0 ary.each do |int| bit |= (1 << int) end bit end |
.to_array(int) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lrama/bitmap.rb', line 18 def self.to_array(int) a = [] #: Array[Integer] i = 0 while int > 0 do if int & 1 == 1 a << i end i += 1 int >>= 1 end a end |