pub struct BitSet<Conf: Config>(/* private fields */);
Expand description

Hierarchical sparse bitset.

Tri-level hierarchy. Highest uint it can hold is Level0BitBlock::size() * Level1BitBlock::size() * DataBitBlock::size().

Only last level contains blocks of actual data. Empty(skipped) data blocks are not allocated.

Structure optimized for intersection speed. (Other inter-bitset operations are in fact fast too - but intersection has lowest algorithmic complexity.) Insert/remove/contains is fast O(1) too.

Implementations§

source§

impl<Conf> BitSet<Conf>
where Conf: Config,

source

pub fn new() -> Self

source

pub const fn max_capacity() -> usize

Max usize, bitset with this Conf can hold.

source

pub fn insert(&mut self, index: usize)

§Safety

Will panic, if index is out of range.

source

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

Returns false if index is invalid/not in bitset.

source

pub unsafe fn remove_unchecked(&mut self, index: usize)

§Safety

index MUST exists in HiSparseBitset!

source§

impl<Conf> BitSet<Conf>
where Conf: Config,

source

pub fn block_iter<'a>(&'a self) -> CachingBlockIter<&'a Self>

source

pub fn iter<'a>(&'a self) -> CachingIndexIter<&'a Self>

source

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

source

pub fn is_empty(&self) -> bool

Trait Implementations§

source§

impl<Conf, Rhs> BitAnd<Rhs> for &BitSet<Conf>
where Rhs: BitSetInterface<Conf = <Self as BitSetBase>::Conf>, Conf: Config,

source§

fn bitand(self, rhs: Rhs) -> Self::Output

Returns intersection of self and rhs bitsets.

§

type Output = Apply<And, &BitSet<Conf>, Rhs>

The resulting type after applying the & operator.
source§

impl<Conf, Rhs> BitOr<Rhs> for &BitSet<Conf>
where Rhs: BitSetInterface<Conf = <Self as BitSetBase>::Conf>, Conf: Config,

source§

fn bitor(self, rhs: Rhs) -> Self::Output

Returns union of self and rhs bitsets.

§

type Output = Apply<Or, &BitSet<Conf>, Rhs>

The resulting type after applying the | operator.
source§

impl<Conf: Config> BitSetBase for BitSet<Conf>

§

type Conf = Conf

source§

const TRUSTED_HIERARCHY: bool = true

Does each raised bit in hierarchy bitblock correspond to non-empty data block? Read more
source§

impl<Conf> BitSetInterface for &BitSet<Conf>
where Conf: Config,

source§

impl<Conf, Rhs> BitXor<Rhs> for &BitSet<Conf>
where Rhs: BitSetInterface<Conf = <Self as BitSetBase>::Conf>, Conf: Config,

source§

fn bitxor(self, rhs: Rhs) -> Self::Output

Returns symmetric difference of self and rhs bitsets.

§

type Output = Apply<Xor, &BitSet<Conf>, Rhs>

The resulting type after applying the ^ operator.
source§

impl<Conf> Clone for BitSet<Conf>
where Conf: Config,

source§

fn clone(&self) -> Self

Returns a copy 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<Conf> Debug for BitSet<Conf>
where Conf: Config,

source§

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

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

impl<Conf> Default for BitSet<Conf>
where Conf: Config,

source§

fn default() -> Self

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

impl<Conf, const N: usize> From<[usize; N]> for BitSet<Conf>
where Conf: Config,

source§

fn from(value: [usize; N]) -> Self

Converts to this type from the input type.
source§

impl<Conf> FromIterator<usize> for BitSet<Conf>
where Conf: Config,

source§

fn from_iter<T: IntoIterator<Item = usize>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<Conf> IntoIterator for &BitSet<Conf>
where Conf: Config,

§

type Item = usize

The type of the elements being iterated over.
§

type IntoIter = CachingIndexIter<&BitSet<Conf>>

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<Conf> LevelMasks for BitSet<Conf>
where Conf: Config,

source§

fn level0_mask(&self) -> <Self::Conf as Config>::Level0BitBlock

source§

unsafe fn level1_mask( &self, level0_index: usize ) -> <Self::Conf as Config>::Level1BitBlock

Safety Read more
source§

unsafe fn data_mask( &self, level0_index: usize, level1_index: usize ) -> <Self::Conf as Config>::DataBitBlock

Safety Read more
source§

impl<Conf> LevelMasksIterExt for BitSet<Conf>
where Conf: Config,

§

type IterState = <RawBitSet<Conf, Block<<Conf as Config>::Level0BitBlock, <Conf as Config>::Level0BlockIndices>, Block<<Conf as Config>::Level1BitBlock, <Conf as Config>::Level1BlockIndices>, Block<<Conf as Config>::DataBitBlock, [usize; 0]>> as LevelMasksIterExt>::IterState

Consists from child states (if any) + Self state. Read more
§

type Level1BlockData = <RawBitSet<Conf, Block<<Conf as Config>::Level0BitBlock, <Conf as Config>::Level0BlockIndices>, Block<<Conf as Config>::Level1BitBlock, <Conf as Config>::Level1BlockIndices>, Block<<Conf as Config>::DataBitBlock, [usize; 0]>> as LevelMasksIterExt>::Level1BlockData

Level1 block related data, used to speed up data_mask access. Read more
source§

fn make_iter_state(&self) -> Self::IterState

source§

unsafe fn drop_iter_state(&self, state: &mut ManuallyDrop<Self::IterState>)

Having separate function for drop not strictly necessary, since IterState can actually drop itself. But! This allows not to store cache size within IterState. Which makes FixedCache CacheData ZST, if its childs are ZSTs, and which makes cache construction and destruction noop. Which is important for short iteration sessions. Read more
source§

unsafe fn init_level1_block_data( &self, state: &mut Self::IterState, level1_block_data: &mut MaybeUninit<Self::Level1BlockData>, level0_index: usize ) -> (<Self::Conf as Config>::Level1BitBlock, bool)

Init level1_block_data and return (Level1Mask, is_not_empty). Read more
source§

unsafe fn data_mask_from_block_data( level1_block_data: &Self::Level1BlockData, level1_index: usize ) -> <Self::Conf as Config>::DataBitBlock

Safety Read more
source§

impl<Conf, Rhs> PartialEq<Rhs> for BitSet<Conf>
where Rhs: LevelMasksIterExt<Conf = <Self as BitSetBase>::Conf>, Conf: Config,

source§

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

Works faster with TRUSTED_HIERARCHY.

1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Conf, Rhs> Sub<Rhs> for &BitSet<Conf>
where Rhs: BitSetInterface<Conf = <Self as BitSetBase>::Conf>, Conf: Config,

source§

fn sub(self, rhs: Rhs) -> Self::Output

Returns difference of self and rhs bitsets.

Or relative complement of rhs in self.

§

type Output = Apply<Sub, &BitSet<Conf>, Rhs>

The resulting type after applying the - operator.
source§

impl<Conf> Eq for BitSet<Conf>
where Conf: Config,

Auto Trait Implementations§

§

impl<Conf> RefUnwindSafe for BitSet<Conf>

§

impl<Conf> Send for BitSet<Conf>
where Conf: Send, <Conf as Config>::DataBitBlock: Send, <Conf as Config>::Level0BitBlock: Send, <Conf as Config>::Level0BlockIndices: Send, <Conf as Config>::Level1BitBlock: Send, <Conf as Config>::Level1BlockIndices: Send,

§

impl<Conf> Sync for BitSet<Conf>
where Conf: Sync, <Conf as Config>::DataBitBlock: Sync, <Conf as Config>::Level0BitBlock: Sync, <Conf as Config>::Level0BlockIndices: Sync, <Conf as Config>::Level1BitBlock: Sync, <Conf as Config>::Level1BlockIndices: Sync,

§

impl<Conf> Unpin for BitSet<Conf>
where Conf: Unpin, <Conf as Config>::DataBitBlock: Unpin, <Conf as Config>::Level0BitBlock: Unpin, <Conf as Config>::Level0BlockIndices: Unpin, <Conf as Config>::Level1BitBlock: Unpin, <Conf as Config>::Level1BlockIndices: Unpin,

§

impl<Conf> UnwindSafe for BitSet<Conf>

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.