pub struct BitSet<T> {
    domain_size: usize,
    words: Vec<u64>,
    marker: PhantomData<T>,
}
Expand description

A fixed-size bitset type with a dense representation.

NOTE: Use GrowableBitSet if you need support for resizing after creation.

T is an index type, typically a newtyped usize wrapper, but it can also just be usize.

All operations that involve an element will panic if the element is equal to or greater than the domain size. All operations that involve two bitsets will panic if the bitsets have differing domain sizes.

Fields

domain_size: usizewords: Vec<u64>marker: PhantomData<T>

Implementations

Gets the domain size.

Creates a new, empty bitset with a given domain_size.

Creates a new, filled bitset with a given domain_size.

Clear all elements.

Clear excess bits in the final word.

Count the number of set bits in the set.

Returns true if self contains elem.

Is self is a (non-strict) superset of other?

Is the set empty?

Insert elem. Returns whether the set has changed.

Sets all bits to true.

Returns true if the set has changed.

Gets a slice of the underlying words.

Iterates over the indices of set bits in a sorted order.

Duplicates the set as a hybrid set.

Set self = self | other. In contrast to union returns true if the set contains at least one bit that is not in other (i.e. other is not a superset of self).

This is an optimization for union of a hybrid bitset.

Sets self = self | other and returns true if self changed (i.e., if new bits were added).

Sets self = self - other and returns true if self changed. (i.e., if any bits were removed).

Sets self = self & other and return true if self changed. (i.e., if any bits were removed).

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Converts the given value to a String. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes