5.7. Packed boolean array
The BOOL_ARRAY module provides a compact boolean array implementation using
bit-packing. Each boolean value uses a single bit instead of a byte,
providing an 8x memory reduction compared to array<bool>.
All functions and symbols are in “bool_array” module, use require to get access to it.
require daslib/bool_array
5.7.1. Structures
- bool_array.BoolArray
A dynamic array of booleans, stored as bits.
- BoolArray.finalize()
Releases the memory used by the BoolArray.
- BoolArray.[](index: int): bool
Get the boolean value at the given index.
- Arguments:
index : int
- BoolArray.[]=(index: int; value: bool)
Set the boolean value at the given index.
- Arguments:
index : int
value : bool
- BoolArray.[]^^=(index: int; value: bool)
Perform XOR operation on the boolean value at the given index.
- Arguments:
index : int
value : bool
- BoolArray.[]&&=(index: int; value: bool)
Perform AND operation on the boolean value at the given index.
- Arguments:
index : int
value : bool
- BoolArray.[]||=(index: int; value: bool)
Perform OR operation on the boolean value at the given index.
- Arguments:
index : int
value : bool
- BoolArray.clear()
Clear the BoolArray.
- BoolArray.reserve(capacity: int)
Reserve capacity for the BoolArray.
- Arguments:
capacity : int
- BoolArray.resize(newSize: int)
Resize the BoolArray to the new size.
- Arguments:
newSize : int
- BoolArray.push(value: bool)
Push a new boolean value to the end of the BoolArray.
- Arguments:
value : bool
- BoolArray.push(value: bool; at: int)
Push a new boolean value at the given index in the BoolArray.
- Arguments:
value : bool
at : int
- BoolArray.pop(): bool
Pop the last boolean value from the BoolArray and return it.
- BoolArray.length(): int
Get the length of the BoolArray.
- BoolArray.erase(index: int)
Erase the boolean value at the given index from the BoolArray.
- Arguments:
index : int
- BoolArray.insert(index: int; value: bool)
Insert a boolean value at the given index in the BoolArray.
- Arguments:
index : int
value : bool
- BoolArray.to_string(): string
Convert the BoolArray to a string representation.
- BoolArray.data_pointer(): uint?
Warning
This is unsafe operation.
Get the data pointer of the BoolArray.
- BoolArray.data_pointer(): uint const?
Warning
This is unsafe operation.
Get the data pointer of the BoolArray.
5.7.2. Iteration
- bool_array.each(self: BoolArray): iterator<bool>
Returns an iterator over all boolean values in the BoolArray.
- Arguments:
self : BoolArray