Skip to main content

SparseBitset

Struct SparseBitset 

Source
pub struct SparseBitset { /* private fields */ }
Expand description

A set of instances that supports intersection and constant-time undo.

Words that become zero are moved out of the active part of non_zero_words, so later operations only visit non-empty words.

Implementations§

Source§

impl SparseBitset

Source

pub fn new(n: usize) -> Self

The full set 0..n.

Source

pub fn count(&self) -> usize

Number of elements.

Source

pub fn is_empty(&self) -> bool

Whether the set is empty.

Source

pub fn intersect_with(&mut self, other: &Bitset, invert: bool) -> usize

Intersects with other (with its complement when invert), saving the current state for Self::restore. Returns the new size.

Source

pub fn count_intersect_with(&self, other: &Bitset, invert: bool) -> usize

Size of the intersection with other (or its complement), without changing the set.

Source

pub fn count_intersect_with_many(&self, others: &[Bitset]) -> Vec<usize>

Size of the intersection with each of others.

Source

pub fn to_vec(&self) -> Vec<usize>

The elements of the set.

Source

pub fn restore(&mut self)

Undoes the last intersection.

Trait Implementations§

Source§

impl From<&SparseBitset> for ShallowBitset

Source§

fn from(val: &SparseBitset) -> Self

Converts to this type from the input type.
Source§

impl Sub<&ShallowBitset> for &SparseBitset

in_count counts the elements of self missing from rhs, and out_count the elements of rhs missing from self.

Source§

type Output = Difference

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &ShallowBitset) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&ShallowBitset> for SparseBitset

Source§

type Output = Difference

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &ShallowBitset) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<ShallowBitset> for SparseBitset

Source§

type Output = Difference

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ShallowBitset) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<ShallowBitset> for &SparseBitset

Source§

type Output = Difference

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ShallowBitset) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.