mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
std.BitSet: add setAll and unsetAll methods
This commit is contained in:
parent
815b85d8a2
commit
09d13104be
@ -859,6 +859,18 @@ pub const DynamicBitSetUnmanaged = struct {
|
||||
self.masks[maskIndex(index)] &= ~maskBit(index);
|
||||
}
|
||||
|
||||
/// Set all bits to 0.
|
||||
pub fn unsetAll(self: *Self) void {
|
||||
const masks_len = numMasks(self.bit_length);
|
||||
@memset(self.masks[0..masks_len], 0);
|
||||
}
|
||||
|
||||
/// Set all bits to 1.
|
||||
pub fn setAll(self: *Self) void {
|
||||
const masks_len = numMasks(self.bit_length);
|
||||
@memset(self.masks[0..masks_len], std.math.maxInt(MaskInt));
|
||||
}
|
||||
|
||||
/// Flips a specific bit in the bit set
|
||||
pub fn toggle(self: *Self, index: usize) void {
|
||||
assert(index < self.bit_length);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user