struct BitArray
Overview
BitArray
is an array data structure that compactly stores bits.
Bits externally represented as Bool
s are stored internally as
UInt32
s. The total number of bits stored is set at creation and is
immutable.
NOTE To use BitArray
, you must explicitly import it with require "bit_array"
Example
require "bit_array"
ba = BitArray.new(12) # => "BitArray[000000000000]"
ba[2] # => false
0.upto(5) { |i| ba[i * 2] = true }
ba # => "BitArray[101010101010]"
ba[2] # => true
Included Modules
- Indexable::Mutable(Bool)
Defined in:
byte_serializer.crClass Method Summary
Instance Method Summary
Instance methods inherited from module Enumerable(Bool)
tabulate(io)
tabulate
Instance methods inherited from class Object
tabulate(io)tabulate tabulate, tap(&) tap