Struct tinybitset::TinyBitSet
source · pub struct TinyBitSet<T: BitBlock, const N: usize> { /* private fields */ }Expand description
A small, fixed size bitset that stores its data inline.
Storage and indexing
The bitsets storage consists of N blocks of type T, where T is any of
the unsigned integer types implementing BitBlock. Thus, the bitset has a
fixed size of T::BITS * N bits can be freely converted to and from the
array of blocks.
The bits are indexed from front to back within the array of blocks, and from
least significant to most significant within each block. Thus, the bit with
index i is stored in the (i / T::BITS)-th block in the (i % T::BITS)-th least significant bit.
Implementations§
source§impl<T: BitBlock, const N: usize> TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> TinyBitSet<T, N>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates an empty bitset.
Equivalent to Self::EMPTY.
sourcepub const fn capacity(self) -> usize
pub const fn capacity(self) -> usize
Number of bits in the bitset.
Equivalent to Self::CAPACITY.
sourcepub fn iter(self) -> IntoIter<T, N> ⓘ
pub fn iter(self) -> IntoIter<T, N> ⓘ
Iterates over the indices of set bits from lowest to highest.
sourcepub fn iter_missing(self) -> IntoIter<T, N> ⓘ
pub fn iter_missing(self) -> IntoIter<T, N> ⓘ
Iterates over the indices of unset bits from lowest to highest.
Trait Implementations§
source§impl<T: BitBlock, const N: usize> BitAndAssign for TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> BitAndAssign for TinyBitSet<T, N>
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moresource§impl<T: BitBlock, const N: usize> BitOrAssign for TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> BitOrAssign for TinyBitSet<T, N>
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moresource§impl<T: BitBlock, const N: usize> BitXorAssign for TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> BitXorAssign for TinyBitSet<T, N>
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read moresource§impl<T: Clone + BitBlock, const N: usize> Clone for TinyBitSet<T, N>
impl<T: Clone + BitBlock, const N: usize> Clone for TinyBitSet<T, N>
source§fn clone(&self) -> TinyBitSet<T, N>
fn clone(&self) -> TinyBitSet<T, N>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<T: BitBlock, const N: usize> Default for TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> Default for TinyBitSet<T, N>
source§fn default() -> Self
fn default() -> Self
Returns Self::EMPTY.
source§impl<T: BitBlock, const N: usize> From<[T; N]> for TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> From<[T; N]> for TinyBitSet<T, N>
source§fn from(blocks: [T; N]) -> Self
fn from(blocks: [T; N]) -> Self
Create a bitset from the underlying bit blocks.
See TinyBitSet for more information on how the bits are indexed.
source§impl<T: BitBlock> From<T> for TinyBitSet<T, 1>
impl<T: BitBlock> From<T> for TinyBitSet<T, 1>
source§impl<T: BitBlock, const N: usize> From<TinyBitSet<T, N>> for [T; N]
impl<T: BitBlock, const N: usize> From<TinyBitSet<T, N>> for [T; N]
source§fn from(bitset: TinyBitSet<T, N>) -> Self
fn from(bitset: TinyBitSet<T, N>) -> Self
Convert the bitset into the underlying bit blocks.
See TinyBitSet for more information on how the bits are indexed.
source§impl From<TinyBitSet<u128, 1>> for u128
impl From<TinyBitSet<u128, 1>> for u128
source§fn from(bitset: TinyBitSet<u128, 1>) -> Self
fn from(bitset: TinyBitSet<u128, 1>) -> Self
Convert the bitset into the underlying bit block.
Due to the orphan rule, this cannot be covered by a blanket implementation and is thus separately implemented for all primitive integer types.
source§impl From<TinyBitSet<u16, 1>> for u16
impl From<TinyBitSet<u16, 1>> for u16
source§fn from(bitset: TinyBitSet<u16, 1>) -> Self
fn from(bitset: TinyBitSet<u16, 1>) -> Self
Convert the bitset into the underlying bit block.
Due to the orphan rule, this cannot be covered by a blanket implementation and is thus separately implemented for all primitive integer types.
source§impl From<TinyBitSet<u32, 1>> for u32
impl From<TinyBitSet<u32, 1>> for u32
source§fn from(bitset: TinyBitSet<u32, 1>) -> Self
fn from(bitset: TinyBitSet<u32, 1>) -> Self
Convert the bitset into the underlying bit block.
Due to the orphan rule, this cannot be covered by a blanket implementation and is thus separately implemented for all primitive integer types.
source§impl From<TinyBitSet<u64, 1>> for u64
impl From<TinyBitSet<u64, 1>> for u64
source§fn from(bitset: TinyBitSet<u64, 1>) -> Self
fn from(bitset: TinyBitSet<u64, 1>) -> Self
Convert the bitset into the underlying bit block.
Due to the orphan rule, this cannot be covered by a blanket implementation and is thus separately implemented for all primitive integer types.
source§impl From<TinyBitSet<u8, 1>> for u8
impl From<TinyBitSet<u8, 1>> for u8
source§fn from(bitset: TinyBitSet<u8, 1>) -> Self
fn from(bitset: TinyBitSet<u8, 1>) -> Self
Convert the bitset into the underlying bit block.
Due to the orphan rule, this cannot be covered by a blanket implementation and is thus separately implemented for all primitive integer types.
source§impl<T: BitBlock, const N: usize> FromIterator<usize> for TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> FromIterator<usize> for TinyBitSet<T, N>
source§impl<T: BitBlock, const N: usize> IntoIterator for &TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> IntoIterator for &TinyBitSet<T, N>
source§impl<T: BitBlock, const N: usize> IntoIterator for TinyBitSet<T, N>
impl<T: BitBlock, const N: usize> IntoIterator for TinyBitSet<T, N>
source§impl<T: Ord + BitBlock, const N: usize> Ord for TinyBitSet<T, N>
impl<T: Ord + BitBlock, const N: usize> Ord for TinyBitSet<T, N>
source§fn cmp(&self, other: &TinyBitSet<T, N>) -> Ordering
fn cmp(&self, other: &TinyBitSet<T, N>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialEq + BitBlock, const N: usize> PartialEq for TinyBitSet<T, N>
impl<T: PartialEq + BitBlock, const N: usize> PartialEq for TinyBitSet<T, N>
source§fn eq(&self, other: &TinyBitSet<T, N>) -> bool
fn eq(&self, other: &TinyBitSet<T, N>) -> bool
self and other values to be equal, and is used
by ==.source§impl<T: PartialOrd + BitBlock, const N: usize> PartialOrd for TinyBitSet<T, N>
impl<T: PartialOrd + BitBlock, const N: usize> PartialOrd for TinyBitSet<T, N>
source§fn partial_cmp(&self, other: &TinyBitSet<T, N>) -> Option<Ordering>
fn partial_cmp(&self, other: &TinyBitSet<T, N>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more