Struct hi_sparse_bitset::BitSet
source · 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,
impl<Conf> BitSet<Conf>where
Conf: Config,
pub fn new() -> Self
sourcepub const fn max_capacity() -> usize
pub const fn max_capacity() -> usize
Max usize, bitset with this Conf
can hold.
sourcepub fn remove(&mut self, index: usize) -> bool
pub fn remove(&mut self, index: usize) -> bool
Returns false if index is invalid/not in bitset.
sourcepub unsafe fn remove_unchecked(&mut self, index: usize)
pub unsafe fn remove_unchecked(&mut self, index: usize)
§Safety
index
MUST exists in HiSparseBitset!
Trait Implementations§
source§impl<Conf: Config> BitSetBase for BitSet<Conf>
impl<Conf: Config> BitSetBase for BitSet<Conf>
source§impl<Conf> BitSetInterface for &BitSet<Conf>where
Conf: Config,
impl<Conf> BitSetInterface for &BitSet<Conf>where
Conf: Config,
fn block_iter(&self) -> CachingBlockIter<&Self> ⓘ
fn iter(&self) -> CachingIndexIter<&Self> ⓘ
fn into_block_iter(self) -> CachingBlockIter<Self> ⓘ
fn contains(&self, index: usize) -> bool
source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
O(1) if TRUSTED_HIERARCHY, O(N) otherwise.
source§impl<Conf> IntoIterator for &BitSet<Conf>where
Conf: Config,
impl<Conf> IntoIterator for &BitSet<Conf>where
Conf: Config,
source§impl<Conf> LevelMasks for BitSet<Conf>where
Conf: Config,
impl<Conf> LevelMasks for BitSet<Conf>where
Conf: Config,
fn level0_mask(&self) -> <Self::Conf as Config>::Level0BitBlock
source§unsafe fn level1_mask(
&self,
level0_index: usize
) -> <Self::Conf as Config>::Level1BitBlock
unsafe fn level1_mask( &self, level0_index: usize ) -> <Self::Conf as Config>::Level1BitBlock
Safety Read more
source§impl<Conf> LevelMasksIterExt for BitSet<Conf>where
Conf: Config,
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
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
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
fn make_iter_state(&self) -> Self::IterState
source§unsafe fn drop_iter_state(&self, state: &mut ManuallyDrop<Self::IterState>)
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)
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 moresource§unsafe fn data_mask_from_block_data(
level1_block_data: &Self::Level1BlockData,
level1_index: usize
) -> <Self::Conf as Config>::DataBitBlock
unsafe fn data_mask_from_block_data( level1_block_data: &Self::Level1BlockData, level1_index: usize ) -> <Self::Conf as Config>::DataBitBlock
Safety Read more
impl<Conf> Eq for BitSet<Conf>where
Conf: Config,
Auto Trait Implementations§
impl<Conf> RefUnwindSafe for BitSet<Conf>where
Conf: RefUnwindSafe,
<Conf as Config>::DataBitBlock: RefUnwindSafe,
<Conf as Config>::Level0BitBlock: RefUnwindSafe,
<Conf as Config>::Level0BlockIndices: RefUnwindSafe,
<Conf as Config>::Level1BitBlock: RefUnwindSafe,
<Conf as Config>::Level1BlockIndices: RefUnwindSafe,
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>where
Conf: UnwindSafe,
<Conf as Config>::DataBitBlock: UnwindSafe,
<Conf as Config>::Level0BitBlock: UnwindSafe,
<Conf as Config>::Level0BlockIndices: UnwindSafe,
<Conf as Config>::Level1BitBlock: UnwindSafe,
<Conf as Config>::Level1BlockIndices: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more