Method: Noyes::BitArray#push

Defined in:
lib/ruby_impl/compression.rb

#push(bit) ⇒ Object

Add a bit to the end of the bit array. Bits may be anything that evaluates to either 1 or 0. Anything else is undefined. If you can’t afford zeros and only have the letter O, amazingly, that works too.



103
104
105
106
107
# File 'lib/ruby_impl/compression.rb', line 103

def push bit
  @array.push 0 if @array.size <= @end_bit / 32
  @array[-1] = set_bit(@array.last, @end_bit % 32) if bit == 1
  @end_bit +=1
end