This language bar is your friend. Select your favorite languages!
Select your favorite languages :
- Or search :
x := make([]uint64, (n+63)/64)
This compact bitset requires some extra logic to implement get, set, clear (see demo).
x := make([]bool, n)
This makes a simple fixed-size bitset.
It uses more bits in memory than the useful size n.
It uses more bits in memory than the useful size n.
procedure Task;
var
x: Set Of Byte;
begin
x:= [2,4,8,16,32,64,256];
end;
when the set contains less than 256 elements the built-in Set Of construct can be used.
procedure task;
var
x: TBits;
n: integer;
begin
n := $FFF;
x := TBits.Create(n);
end;
when the set contains more than 256 elements the class TBits must be used
vec($x, $n, 1) = 0;
Creates bitset (containing all zeros) of $n bits (rounded up to the nearest multiple of 8). To extend it, just set another 0 (or 1) bit at the new width you want.