pub struct ChunkedBitSet<T> {
    domain_size: usize,
    chunks: Box<[Chunk]>,
    marker: PhantomData<T>,
}
Expand description

A fixed-size bitset type with a partially dense, partially sparse representation. The bitset is broken into chunks, and chunks that are all zeros or all ones are represented and handled very efficiently.

This type is especially efficient for sets that typically have a large domain_size with significant stretches of all zeros or all ones, and also some stretches with lots of 0s and 1s mixed in a way that causes trouble for IntervalSet.

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: usizechunks: Box<[Chunk]>

The chunks. Each one contains exactly CHUNK_BITS values, except the last one which contains 1..=CHUNK_BITS values.

marker: PhantomData<T>

Implementations

Creates a new bitset with a given domain_size and chunk kind.

Creates a new, empty bitset with a given domain_size.

Creates a new, filled bitset with a given domain_size.

Count the number of bits in the set.

Returns true if self contains elem.

Insert elem. Returns whether the set has changed.

Sets all bits to true.

Returns true if the set has changed.

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

WARNING: this implementation of clone_from will panic if the two bitsets have different domain sizes. This constraint is not inherent to clone_from, but it works with the existing call sites and allows a faster implementation, which is important because this function is hot.

Returns a copy of the value. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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: 24 bytes