Struct BitSet

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

A BitSet is a simple set designed to track which indices are placed into it.

Note, a BitSet is limited by design to only usize**4 indices. Adding beyond this limit will cause the BitSet to panic.

Implementations§

Source§

impl BitSet

Source

pub fn new() -> BitSet

Creates an empty BitSet.

Source

pub fn with_capacity(max: u32) -> BitSet

Creates an empty BitSet, preallocated for up to max indices.

Source

pub fn add(&mut self, id: u32) -> bool

Adds id to the BitSet. Returns true if the value was already in the set.

Source

pub fn remove(&mut self, id: u32) -> bool

Removes id from the set, returns true if the value was removed, and false if the value was not set to begin with.

Source

pub fn contains(&self, id: u32) -> bool

Returns true if id is in the set.

Source

pub fn clear(&mut self)

Completely wipes out the bit set.

Trait Implementations§

Source§

impl<'a, T> BitAnd<T> for &'a BitSet
where T: BitSetLike,

Source§

type Output = BitSetAnd<&'a BitSet, T>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: T) -> <&'a BitSet as BitAnd<T>>::Output

Performs the & operation. Read more
Source§

impl<T> BitAnd<T> for BitSet
where T: BitSetLike,

Source§

type Output = BitSetAnd<BitSet, T>

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: T) -> <BitSet as BitAnd<T>>::Output

Performs the & operation. Read more
Source§

impl<'a, B> BitAndAssign<&'a B> for BitSet
where B: BitSetLike,

Source§

fn bitand_assign(&mut self, lhs: &B)

Performs the &= operation. Read more
Source§

impl<'a, T> BitOr<T> for &'a BitSet
where T: BitSetLike,

Source§

type Output = BitSetOr<&'a BitSet, T>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: T) -> <&'a BitSet as BitOr<T>>::Output

Performs the | operation. Read more
Source§

impl<T> BitOr<T> for BitSet
where T: BitSetLike,

Source§

type Output = BitSetOr<BitSet, T>

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: T) -> <BitSet as BitOr<T>>::Output

Performs the | operation. Read more
Source§

impl<'a, B> BitOrAssign<&'a B> for BitSet
where B: BitSetLike,

Source§

fn bitor_assign(&mut self, lhs: &B)

Performs the |= operation. Read more
Source§

impl BitSetLike for BitSet

Source§

fn layer3(&self) -> usize

Return a usize where each bit represents if any word in layer2 has been set.
Source§

fn layer2(&self, i: usize) -> usize

Return the usize from the array of usizes that indicates if any bit has been set in layer1
Source§

fn layer1(&self, i: usize) -> usize

Return the usize from the array of usizes that indicates if any bit has been set in layer0
Source§

fn layer0(&self, i: usize) -> usize

Return a usize that maps to the direct 1:1 association with each index of the set
Source§

fn contains(&self, i: u32) -> bool

Allows checking if set bit is contained in the bit set.
Source§

fn get_from_layer(&self, layer: usize, idx: usize) -> usize

Gets the usize corresponding to layer and index. Read more
Source§

fn is_empty(&self) -> bool

Returns true if this BitSetLike contains nothing, and false otherwise.
Source§

fn iter(self) -> BitIter<Self>
where Self: Sized,

Create an iterator that will scan over the keyspace
Source§

impl<'a, T> BitXor<T> for &'a BitSet
where T: BitSetLike,

Source§

type Output = BitSetXor<&'a BitSet, T>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: T) -> <&'a BitSet as BitXor<T>>::Output

Performs the ^ operation. Read more
Source§

impl<T> BitXor<T> for BitSet
where T: BitSetLike,

Source§

type Output = BitSetXor<BitSet, T>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: T) -> <BitSet as BitXor<T>>::Output

Performs the ^ operation. Read more
Source§

impl<'a, B> BitXorAssign<&'a B> for BitSet
where B: BitSetLike,

Source§

fn bitxor_assign(&mut self, lhs: &B)

Performs the ^= operation. Read more
Source§

impl Clone for BitSet

Source§

fn clone(&self) -> BitSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BitSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for BitSet

Source§

fn default() -> BitSet

Returns the “default value” for a type. Read more
Source§

impl DrainableBitSet for BitSet

Source§

fn remove(&mut self, i: u32) -> bool

Removes bit from the bit set. Read more
Source§

fn drain<'a>(&'a mut self) -> DrainBitIter<'a, Self>
where Self: Sized,

Create a draining iterator that will scan over the keyspace and clears it while doing so.
Source§

impl<'a> Extend<&'a u32> for BitSet

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = &'a u32>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<u32> for BitSet

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = u32>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<'a> FromIterator<&'a u32> for BitSet

Source§

fn from_iter<T>(iter: T) -> BitSet
where T: IntoIterator<Item = &'a u32>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<u32> for BitSet

Source§

fn from_iter<T>(iter: T) -> BitSet
where T: IntoIterator<Item = u32>,

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a BitSet

Source§

type Item = <BitIter<&'a BitSet> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = BitIter<&'a BitSet>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a BitSet as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for BitSet

Source§

type Item = <BitIter<BitSet> as Iterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = BitIter<BitSet>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <BitSet as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> Join for &'a BitSet

Source§

type Type = u32

Type of joined components.
Source§

type Value = ()

Type of joined storages.
Source§

type Mask = &'a BitSet

Type of joined bit mask.
Source§

unsafe fn open( self, ) -> (<&'a BitSet as Join>::Mask, <&'a BitSet as Join>::Value)

Open this join by returning the mask and the storages. Read more
Source§

unsafe fn get( _: &mut <&'a BitSet as Join>::Value, id: u32, ) -> <&'a BitSet as Join>::Type

Get a joined component value by a given index.
Source§

fn join(self) -> JoinIter<Self>
where Self: Sized,

Create a joined iterator over the contents.
Source§

fn maybe(self) -> MaybeJoin<Self>
where Self: Sized,

Returns a Join-able structure that yields all indices, returning None for all missing elements and Some(T) for found elements. Read more
Source§

fn is_unconstrained() -> bool

If this Join typically returns all indices in the mask, then iterating over only it or combined with other joins that are also dangerous will cause the JoinIter/ParJoin to go through all indices which is usually not what is wanted and will kill performance.
Source§

impl Join for BitSet

Source§

type Type = u32

Type of joined components.
Source§

type Value = ()

Type of joined storages.
Source§

type Mask = BitSet

Type of joined bit mask.
Source§

unsafe fn open(self) -> (<BitSet as Join>::Mask, <BitSet as Join>::Value)

Open this join by returning the mask and the storages. Read more
Source§

unsafe fn get( _: &mut <BitSet as Join>::Value, id: u32, ) -> <BitSet as Join>::Type

Get a joined component value by a given index.
Source§

fn join(self) -> JoinIter<Self>
where Self: Sized,

Create a joined iterator over the contents.
Source§

fn maybe(self) -> MaybeJoin<Self>
where Self: Sized,

Returns a Join-able structure that yields all indices, returning None for all missing elements and Some(T) for found elements. Read more
Source§

fn is_unconstrained() -> bool

If this Join typically returns all indices in the mask, then iterating over only it or combined with other joins that are also dangerous will cause the JoinIter/ParJoin to go through all indices which is usually not what is wanted and will kill performance.
Source§

impl<'a> Not for &'a BitSet

Source§

type Output = BitSetNot<&'a BitSet>

The resulting type after applying the ! operator.
Source§

fn not(self) -> <&'a BitSet as Not>::Output

Performs the unary ! operation. Read more
Source§

impl Not for BitSet

Source§

type Output = BitSetNot<BitSet>

The resulting type after applying the ! operator.
Source§

fn not(self) -> <BitSet as Not>::Output

Performs the unary ! operation. Read more

Auto Trait Implementations§

§

impl Freeze for BitSet

§

impl RefUnwindSafe for BitSet

§

impl Send for BitSet

§

impl Sync for BitSet

§

impl Unpin for BitSet

§

impl UnwindSafe for BitSet

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

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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> TryDefault for T
where T: Default,

Source§

fn try_default() -> Result<T, String>

Tries to create the default.
Source§

fn unwrap_default() -> Self

Calls try_default and panics on an error case.
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.
Source§

impl<T> Erased for T

Source§

impl<T> Event for T
where T: Send + Sync + 'static,

Source§

impl<T> Resource for T
where T: Any + Send + Sync,