Module: Ibex::LALR::IELR::Bits

Defined in:
lib/ibex/lalr/ielr/bits.rb

Class Method Summary collapse

Class Method Details

.each_set_bit(bits) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/ibex/lalr/ielr/bits.rb', line 14

def each_set_bit(bits)
  return enum_for(:each_set_bit, bits) unless block_given?

  index = 0
  while bits.positive?
    yield index if bits.odd?
    bits >>= 1
    index += 1
  end
end