Struct indexical::impls::BitSet

pub struct BitSet<T> { /* private fields */ }
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.

Trait Implementations§

source§

impl BitSet for BitSet<usize>

§

type Iter<'a> = BitIter<'a, usize>

Type of iterator returned by iter.
source§

fn empty(size: usize) -> Self

Constructs a new bit-set with a domain of size size.
source§

fn contains(&self, index: usize) -> bool

Returns true if index is 1.
source§

fn insert(&mut self, index: usize) -> bool

Sets index to 1, returning true if self changed.
source§

fn iter(&self) -> Self::Iter<'_>

Returns an iterator over all the indices of ones in the bit-set.
source§

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

Removes all ones in self not in other.
source§

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

Removes all ones in self not in other, returning true if self changed.
source§

fn len(&self) -> usize

Returns the number of ones in the bit-set.
source§

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

Adds all ones from other to self.
source§

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

Adds all ones from other to self, returning true if self changed.
source§

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

Removes all ones from other in self.
source§

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

Removes all ones from other in self, returning true if self changed.
source§

fn clear(&mut self)

Sets all bits to 0.
source§

fn invert(&mut self)

Flips all bits in self.
source§

fn insert_all(&mut self)

Adds every element of the domain to self.
source§

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

Copies other into self. Must have the same lengths.
source§

fn is_empty(&self) -> bool

Returns true if there are no ones in the bit-set.
source§

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

Returns true if all ones in other are a one in self.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for BitSet<T>
where T: RefUnwindSafe,

§

impl<T> Send for BitSet<T>
where T: Send,

§

impl<T> Sync for BitSet<T>
where T: Sync,

§

impl<T> Unpin for BitSet<T>
where T: Unpin,

§

impl<T> UnwindSafe for BitSet<T>
where T: UnwindSafe,

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.