Bitmap
A fixed number of on/off bits, numbered from 0. The width is the Bits passed to Bitmap.new. An index outside
0 to Bits - 1 is ignored: Set, Clear and Toggle do nothing, and Test returns false.
local Seen = Collections.Bitmap.new({ Bits = 64 })Seen:Set(3)print(Seen:Test(3), Seen:PopCount()) -- true 1Summary
Section titled “Summary”| Member | Description |
|---|---|
.new() |
Creates a bitmap of Bits bits, all off. |
:Set() |
Turns the bit at Index on. |
:Clear() |
Turns the bit at Index off. |
:Toggle() |
Flips the bit at Index. |
:Test() |
Whether the bit at Index is on. |
:ClearAll() |
Turns every bit off. |
:SetAll() |
Turns every bit on. |
:PopCount() |
How many bits are on. |
:Raw() |
Returns the buffer that holds the bits. |
Functions
Section titled “Functions”function Bitmap.new(Config: { Bits: number }): BitmapCreates a bitmap of Bits bits, all off. Its width cannot change later.
Methods
Section titled “Methods”function Bitmap:Set(Index: number)Turns the bit at Index on.
function Bitmap:Clear(Index: number)Turns the bit at Index off.
Toggle
Section titled “Toggle”function Bitmap:Toggle(Index: number)Flips the bit at Index.
function Bitmap:Test(Index: number): booleanWhether the bit at Index is on.
ClearAll
Section titled “ClearAll”function Bitmap:ClearAll()Turns every bit off.
SetAll
Section titled “SetAll”function Bitmap:SetAll()Turns every bit on.
PopCount
Section titled “PopCount”function Bitmap:PopCount(): numberHow many bits are on.
function Bitmap:Raw(): bufferReturns the buffer that holds the bits. Bit i is bit i % 32 of the u32 at byte (i // 32) * 4, and the bits past the width stay off.
© 2026 PRMS Developer