pub struct Bitset<N, B = usize>where
B: Primitive,
N: CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,{ /* private fields */ }
Expand description
A set of unsigned integers whose size is fixed at compile-time.
A Bitset
can only store unsigned integers less than N
, where N
is a compile-time integer
from typenum
. A Bitset
uses a single bit to indicate the presence or absence of each value.
Implementations§
Source§impl<N, B> Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
impl<N, B> Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Sourcepub fn contains(&self, value: usize) -> bool
pub fn contains(&self, value: usize) -> bool
Returns true
if the bitset contains a value.
Panics if value >= N
.
Sourcepub fn insert(&mut self, value: usize)
pub fn insert(&mut self, value: usize)
Inserts a value into the bitset.
If that value already exists in the bitset, this function has no effect.
Panics if value >= N
.
Sourcepub fn remove(&mut self, value: usize)
pub fn remove(&mut self, value: usize)
Removes a value from the bitset.
If that value does not already exist in the bitset, this function has no effect.
Panics if value >= N
.
Sourcepub fn iter(&self) -> impl '_ + Iterator<Item = usize> + Clone
pub fn iter(&self) -> impl '_ + Iterator<Item = usize> + Clone
Returns an iterator over the values in the bitset.
Sourcepub fn union<'a>(&'a self, other: &'a Self) -> impl 'a + Iterator<Item = usize>
pub fn union<'a>(&'a self, other: &'a Self) -> impl 'a + Iterator<Item = usize>
Returns an iterator over self | other
.
Sourcepub fn intersection<'a>(
&'a self,
other: &'a Self,
) -> impl 'a + Iterator<Item = usize>
pub fn intersection<'a>( &'a self, other: &'a Self, ) -> impl 'a + Iterator<Item = usize>
Returns an iterator over self & other
.
Sourcepub fn symmetric_difference<'a>(
&'a self,
other: &'a Self,
) -> impl 'a + Iterator<Item = usize>
pub fn symmetric_difference<'a>( &'a self, other: &'a Self, ) -> impl 'a + Iterator<Item = usize>
Returns an iterator over self ^ other
.
Sourcepub fn difference<'a>(
&'a self,
other: &'a Self,
) -> impl 'a + Iterator<Item = usize>
pub fn difference<'a>( &'a self, other: &'a Self, ) -> impl 'a + Iterator<Item = usize>
Returns an iterator over self - other
.
Sourcepub fn is_disjoint(&self, other: &Self) -> bool
pub fn is_disjoint(&self, other: &Self) -> bool
Returns true
if self
has no elements in common with other
.
This is more efficient than self.intersection(other).next().is_none()
.
Sourcepub fn is_subset(&self, other: &Self) -> bool
pub fn is_subset(&self, other: &Self) -> bool
Returns true
if every element in self
exists in other
.
Sourcepub fn is_superset(&self, other: &Self) -> bool
pub fn is_superset(&self, other: &Self) -> bool
Returns true
if every element in other
exists in self
.
Trait Implementations§
Source§impl<'a, 'b, N, B> BitAnd<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Intersection
impl<'a, 'b, N, B> BitAnd<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Intersection
Source§impl<N, B> BitAndAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Intersection
impl<N, B> BitAndAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Intersection
Source§fn bitand_assign(&mut self, other: &Self)
fn bitand_assign(&mut self, other: &Self)
&=
operation. Read moreSource§impl<'a, 'b, N, B> BitOr<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Union
impl<'a, 'b, N, B> BitOr<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Union
Source§impl<N, B> BitOrAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Union
impl<N, B> BitOrAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Union
Source§fn bitor_assign(&mut self, other: &Self)
fn bitor_assign(&mut self, other: &Self)
|=
operation. Read moreSource§impl<'a, 'b, N, B> BitXor<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Symmetric Difference
impl<'a, 'b, N, B> BitXor<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Symmetric Difference
Source§impl<N, B> BitXorAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Symmetric Difference
impl<N, B> BitXorAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Symmetric Difference
Source§fn bitxor_assign(&mut self, other: &Self)
fn bitxor_assign(&mut self, other: &Self)
^=
operation. Read moreSource§impl<N, B> Clone for Bitset<N, B>where
B: Primitive,
N: CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
impl<N, B> Clone for Bitset<N, B>where
B: Primitive,
N: CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Source§impl<N, B> Debug for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
impl<N, B> Debug for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Source§impl<N, B> Default for Bitset<N, B>where
B: Primitive,
N: CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
impl<N, B> Default for Bitset<N, B>where
B: Primitive,
N: CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Source§impl<N, B> FromIterator<usize> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
impl<N, B> FromIterator<usize> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Source§impl<N, B> PartialEq for Bitset<N, B>where
B: Primitive,
N: CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
impl<N, B> PartialEq for Bitset<N, B>where
B: Primitive,
N: CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Source§impl<'a, 'b, N, B> Sub<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Difference
impl<'a, 'b, N, B> Sub<&'b Bitset<N, B>> for &'a Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Bitset<N, B>: Clone,
Difference
Source§impl<N, B> SubAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Difference
impl<N, B> SubAssign<&Bitset<N, B>> for Bitset<N, B>where
B: Primitive,
N: Unsigned + CeilDiv<B::Size>,
<N as CeilDiv<B::Size>>::Output: ArrayLength<B>,
Difference
Source§fn sub_assign(&mut self, other: &Self)
fn sub_assign(&mut self, other: &Self)
-=
operation. Read more