Object
Very minimalistic, pure Ruby implementation of bit set. Inspired by java.util.BitSet, although significantly smaller in scope.
Originally part of amqp gem. Extracted to make it possible for Bunny to use it.
Clears all bits in the set @api public
# File lib/amq/bit_set.rb, line 59 def clear self.init_words(@nbits) end
Fetches flag value for given bit.
@param [Integer] A bit to fetch @return [Boolean] true if given bit is set, false otherwise @api public
# File lib/amq/bit_set.rb, line 39 def get(i) w = self.word_index(i) (@words[w] & (1 << i)) != 0 end
Sets (flags) given bit. This method allows bits to be set more than once in a row, no exception will be raised.
@param [Integer] A bit to set @api public
# File lib/amq/bit_set.rb, line 29 def set(i) w = self.word_index(i) @words[w] |= (1 << i) end
Unsets (unflags) given bit. This method allows bits to be unset more than once in a row, no exception will be raised.
@param [Integer] A bit to unset @api public
# File lib/amq/bit_set.rb, line 50 def unset(i) w = self.word_index(i) return if w.nil? @words[w] &= ~(1 << i) end
Generated with the Darkfish Rdoc Generator 2.