Skip to main content

BitSlice

Struct BitSlice 

Source
pub struct BitSlice<T, V>(/* private fields */);
Expand description

Unsized shared base for all bitset types. Wraps a raw [T] primitive slice.

All operations use direct primitive bit manipulation (count_ones, bit masking, etc.), not bitvec’s generic algorithms.

Owned types (BitSet, BoxedBitSet) implement Deref<Target = BitSlice<T, V>> so common methods are defined here once.

Implementations§

Source§

impl<T: PrimInt, V> BitSlice<T, V>

Source

pub fn capacity(&self) -> usize

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn first(&self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn last(&self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn pop_first(&mut self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn pop_last(&mut self) -> Option<V>
where V: TryFrom<usize>,

Source

pub fn contains(&self, id: &V) -> bool
where V: Copy + AsPrimitive<usize>,

Source

pub fn set(&mut self, id: V, value: bool)
where V: AsPrimitive<usize>,

Source

pub fn insert(&mut self, id: V) -> bool
where V: AsPrimitive<usize>,

Source

pub fn remove(&mut self, id: V) -> bool
where V: AsPrimitive<usize>,

Source

pub fn toggle(&mut self, id: V)
where V: AsPrimitive<usize>,

Source

pub fn clear(&mut self)

Source

pub fn retain(&mut self, f: impl FnMut(V) -> bool)
where V: TryFrom<usize>,

Source

pub fn append(&mut self, other: &mut Self)

Source

pub fn iter(&self) -> BitSliceIter<'_, T, V>
where T: BitAndAssign, V: TryFrom<usize>,

Source

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

Source

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

Source

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

Source

pub fn difference<'a>(&'a self, other: &'a Self) -> impl Iterator<Item = V> + 'a
where T: BitAndAssign, V: TryFrom<usize>,

Source

pub fn intersection<'a>( &'a self, other: &'a Self, ) -> impl Iterator<Item = V> + 'a
where T: BitAndAssign, V: TryFrom<usize>,

Source

pub fn union<'a>(&'a self, other: &'a Self) -> impl Iterator<Item = V> + 'a
where T: BitAndAssign, V: TryFrom<usize>,

Source

pub fn symmetric_difference<'a>( &'a self, other: &'a Self, ) -> impl Iterator<Item = V> + 'a
where T: BitAndAssign, V: TryFrom<usize>,

Source

pub fn raw_words(&self) -> &[T]

Raw word slice accessor.

Trait Implementations§

Source§

impl<T: PrimInt + BitAndAssign, V> Debug for BitSlice<T, V>

Source§

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

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

impl<T: PrimInt + Hash, V> Hash for BitSlice<T, V>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl<'a, T: PrimInt + BitAndAssign, V: TryFrom<usize>> IntoIterator for &'a BitSlice<T, V>

Source§

type Item = V

The type of the elements being iterated over.
Source§

type IntoIter = BitSliceIter<'a, T, V>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PrimInt, V> PartialEq for BitSlice<T, V>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PrimInt, V> Eq for BitSlice<T, V>

Auto Trait Implementations§

§

impl<T, V> Freeze for BitSlice<T, V>
where T: Freeze,

§

impl<T, V> RefUnwindSafe for BitSlice<T, V>

§

impl<T, V> Send for BitSlice<T, V>
where V: Send, T: Send,

§

impl<T, V> !Sized for BitSlice<T, V>

§

impl<T, V> Sync for BitSlice<T, V>
where V: Sync, T: Sync,

§

impl<T, V> Unpin for BitSlice<T, V>
where V: Unpin, T: Unpin,

§

impl<T, V> UnsafeUnpin for BitSlice<T, V>
where T: UnsafeUnpin,

§

impl<T, V> UnwindSafe for BitSlice<T, V>
where V: UnwindSafe, 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