struct BitArray

Overview

BitArray is an array data structure that compactly stores bits.

Bits externally represented as Bools are stored internally as UInt32s. 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

Defined in:

byte_serializer.cr

Class 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

Class Method Detail

def self.from_io(io : IO, format = nil) #

[View source]

Instance Method Detail

def from_slice(bytes : Bytes) #

[View source]
def to_io(io : IO, format = nil) #

[View source]