fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type

A bit set with static size, which is backed by an array of usize. This set is good for sets with a larger size, but may use more bytes than necessary if your set is small.

Parameters

MaskIntType: type,
size: usize,

Fields

The bit masks, ordered with lower indices first. Padding bits at the end are undefined.

Types

Functions

inline fn capacity(self: Self) usize

Returns the number of bits in this bit set

fn complement(self: Self) Self

Returns the complement bit sets. Bits in the result are set if the correspondin…

Returns the complement bit sets. Bits in the result are set if the corresponding bits were not set.

fn count(self: Self) usize

Returns the total number of set bits in this bit set.

fn differenceWith(self: Self, other: Self) Self

Returns the difference of two bit sets. Bits in the result are set if set in th…

Returns the difference of two bit sets. Bits in the result are set if set in the first but not set in the second set.

fn eql(self: Self, other: Self) bool

Returns true iff every corresponding bit in both bit sets are the same.

fn findFirstSet(self: Self) ?usize

Finds the index of the first set bit. If no bits are set, returns null.

fn initEmpty() Self

Creates a bit set with no elements present.

fn initFull() Self

Creates a bit set with all elements present.

fn intersectWith(self: Self, other: Self) Self

Returns the intersection of two bit sets. Bits in the result are set if the cor…

Returns the intersection of two bit sets. Bits in the result are set if the corresponding bits were set in both inputs.

fn isSet(self: Self, index: usize) bool

Returns true if the bit at the specified index is present in the set, false oth…

Returns true if the bit at the specified index is present in the set, false otherwise.

fn iterator(self: *const Self, comptime options: IteratorOptions) Iterator(options)

Iterates through the items in the set, according to the options. The default op…

Iterates through the items in the set, according to the options. The default options (.{}) will iterate indices of set bits in ascending order. Modifications to the underlying bit set may or may not be observed by the iterator.

fn set(self: *Self, index: usize) void

Adds a specific bit to the bit set

fn setIntersection(self: *Self, other: Self) void

Performs an intersection of two bit sets, and stores the result in the first on…

Performs an intersection of two bit sets, and stores the result in the first one. Bits in the result are set if the corresponding bits were set in both inputs.

fn setRangeValue(self: *Self, range: Range, value: bool) void

Changes the value of all bits in the specified range to match the passed boolea…

Changes the value of all bits in the specified range to match the passed boolean.

fn setUnion(self: *Self, other: Self) void

Performs a union of two bit sets, and stores the result in the first one. Bits…

Performs a union of two bit sets, and stores the result in the first one. Bits in the result are set if the corresponding bits were set in either input.

fn setValue(self: *Self, index: usize, value: bool) void

Changes the value of the specified bit of the bit set to match the passed boole…

Changes the value of the specified bit of the bit set to match the passed boolean.

fn subsetOf(self: Self, other: Self) bool

Returns true iff the first bit set is the subset of the second one.

fn supersetOf(self: Self, other: Self) bool

Returns true iff the first bit set is the superset of the second one.

fn toggle(self: *Self, index: usize) void

Flips a specific bit in the bit set

fn toggleAll(self: *Self) void

Flips every bit in the bit set.

fn toggleFirstSet(self: *Self) ?usize

Finds the index of the first set bit, and unsets it. If no bits are set, return…

Finds the index of the first set bit, and unsets it. If no bits are set, returns null.

fn toggleSet(self: *Self, toggles: Self) void

Flips all bits in this bit set which are present in the toggles bit set.

fn unionWith(self: Self, other: Self) Self

Returns the union of two bit sets. Bits in the result are set if the correspond…

Returns the union of two bit sets. Bits in the result are set if the corresponding bits were set in either input.

fn unset(self: *Self, index: usize) void

Removes a specific bit from the bit set

fn xorWith(self: Self, other: Self) Self

Returns the xor of two bit sets. Bits in the result are set if the correspondin…

Returns the xor of two bit sets. Bits in the result are set if the corresponding bits were not the same in both inputs.

Values

MaskInt
undefined

The integer type used to represent a mask in this bit set

ShiftInt
undefined

The integer type used to shift a mask in this bit set

bit_length
usize

The number of items in this bit set

last_item_mask
type