v0.4.0

BitSet structv0.1.0

Source
A growable set of bits.
pub struct BitSet {
    // private fields
}

Move-only: it owns its words.

Constructors

BitSet

pub func BitSet(allocator: Allocator) -> BitSet

An empty set that spans no bits and has allocated nothing.

NameTypeDescription
allocatorAllocatorwhere the storage comes from

Returns: the set

Source

Methods

Length

pub func Length(&self) -> uint

How many bits the set spans, set or not.

Returns: the length in bits

Source

Resize

pub func Resize(&var self, length: uint)

Spans length bits: new bits are unset, and bits past a shorter length are dropped.

NameTypeDescription
lengthuintthe length in bits

Source

Get

pub func Get(&self, index: uint) -> bool

Whether bit index is set; false for one past the length.

NameTypeDescription
indexuintthe bit

Returns: whether it is set

Source

Set

pub func Set(&var self, index: uint)

Sets bit index, growing the set to span it.

NameTypeDescription
indexuintthe bit

Source

Reset

pub func Reset(&var self, index: uint)

Unsets bit index. A bit past the length is already unset.

NameTypeDescription
indexuintthe bit

Source

Toggle

pub func Toggle(&var self, index: uint)

Flips bit index, growing the set to span it.

NameTypeDescription
indexuintthe bit

Source

Count

pub func Count(&self) -> uint

How many bits are set.

Returns: the count

Source

IsEmpty

pub func IsEmpty(&self) -> bool

Whether no bit is set.

Returns: whether the set is empty

Source

Clear

pub func Clear(&var self)

Unsets every bit, keeping the length.

Source

NextSet

pub func NextSet(&self, from: uint) -> uint?

The lowest set bit at or after from, which walks the set in order.

NameTypeDescription
fromuintwhere to start looking

Returns: the bit, or none when no bit there or after is set

Source

UnionWith

pub func UnionWith(&var self, other: &BitSet)

Sets every bit that is set in other, growing to span it.

NameTypeDescription
other&BitSetthe other set

Source

IntersectWith

pub func IntersectWith(&var self, other: &BitSet)

Unsets every bit that is not set in other.

NameTypeDescription
other&BitSetthe other set

Source

DifferenceWith

pub func DifferenceWith(&var self, other: &BitSet)

Unsets every bit that is set in other.

NameTypeDescription
other&BitSetthe other set

Source

Equals

pub func Equals(&self, other: &BitSet) -> bool

Whether the same bits are set in both, whatever their lengths.

NameTypeDescription
other&BitSetthe other set

Returns: whether they hold the same members

Source