Skip to main content

BitsetStatic

Trait BitsetStatic 

Source
pub trait BitsetStatic: BitsetDyn {
    // Required methods
    fn empty() -> Self;
    fn with_bit(self, bit: usize) -> Self;
    fn with_bits(self, bits: &[usize]) -> Self;
    fn without_bit(self, bit: usize) -> Self;
    fn without_bits(self, bits: &[usize]) -> Self;
    fn intersection_top(&self, other: &Self) -> Option<usize>;
    fn intersects(&self, other: &Self) -> bool;
    fn union_inplace(&mut self, other: &Self);
    fn intersect_inplace(&mut self, other: &Self);
    fn bits(&self) -> impl Iterator<Item = usize>;
}
Expand description

Subset of bitset ops that do not support dynamic dispatch.

Required Methods§

Source

fn empty() -> Self

The bitset with no bits set.

Source

fn with_bit(self, bit: usize) -> Self

Return a copy of this bitset with bit set.

§Panics

If bit > Self::n_bits. The implementation is not permitted to panic if n_bits returns None.

Source

fn with_bits(self, bits: &[usize]) -> Self

Return a copy of this bitset with bits set.

§Panics

If bit > Self::n_bits. The implementation is not permitted to panic if n_bits returns None.

Source

fn without_bit(self, bit: usize) -> Self

Return a copy of this bitset with bit cleared.

§Panics

If bit > Self::n_bits. The implementation is not permitted to panic if n_bits returns None.

Source

fn without_bits(self, bits: &[usize]) -> Self

Return a copy of this bitset with bits set.

§Panics

If bit > Self::n_bits. The implementation is not permitted to panic if n_bits returns None.

Source

fn intersection_top(&self, other: &Self) -> Option<usize>

Get the intersection of this bitset with another and return the topmost shared bit.

Source

fn intersects(&self, other: &Self) -> bool

Report whether this bitset intersects other.

Source

fn union_inplace(&mut self, other: &Self)

Union other’s bits by mutating this value in-place.

Source

fn intersect_inplace(&mut self, other: &Self)

Intersect other’s bits by mutating this value in-place.

Source

fn bits(&self) -> impl Iterator<Item = usize>

Get the indices of all set bits.

§Example
let bs = Bitset256::default().with_bit(1);
assert_eq!(bs.bits().collect::<Vec<_>>(), vec![1]);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<const N_WORDS: usize> BitsetStatic for Bitset<N_WORDS>