pub unsafe trait BitSetInterface: BitSetBase + LevelMasksIterExt + IntoIterator<IntoIter = CachingIndexIter<Self>> + Sized {
    // Provided methods
    fn block_iter(&self) -> CachingBlockIter<&Self>  { ... }
    fn iter(&self) -> CachingIndexIter<&Self>  { ... }
    fn into_block_iter(self) -> CachingBlockIter<Self>  { ... }
    fn contains(&self, index: usize) -> bool { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

Bitset interface.

Implemented for bitset references and optionally for values. So as argument - accept BitSetInterface by value. (Act as kinda forwarding reference in C++)

§Traversing

CachingBlockIter and CachingIndexIter have specialized for_each() implementation and traverse().

Like with most Rust iterators, traversing1 is somewhat faster then iteration. In this particular case, it has noticeable difference in micro-benchmarks. Remember, that iteration is already super-fast, and any tiny change become important at that scale. Hence, this will have effect in really tight loops (like incrementing counter).

§Implementation

Consider using impl_bitset! instead of implementing it manually.

Implementing BitSetInterface for T will make it passable by value to apply, reduce. That may be not what you want, if your type contains heavy data, or your LevelMasksIterExt implementation depends on *Self being stable during iteration. If that is the case - implement only for &T.


  1. Under “traverse” we understand function application for each element of bitset. 

Provided Methods§

source

fn block_iter(&self) -> CachingBlockIter<&Self>

source

fn iter(&self) -> CachingIndexIter<&Self>

source

fn into_block_iter(self) -> CachingBlockIter<Self>

source

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

source

fn is_empty(&self) -> bool

O(1) if TRUSTED_HIERARCHY, O(N) otherwise.

Object Safety§

This trait is not object safe.

Implementors§

source§

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

source§

impl<Conf> BitSetInterface for &SmallBitSet<Conf>
where Conf: SmallConfig,

source§

impl<Op, S1, S2> BitSetInterface for &Apply<Op, S1, S2>
where Op: BitSetOp, S1: BitSetInterface, S2: BitSetInterface<Conf = S1::Conf>,

source§

impl<Op, S1, S2> BitSetInterface for Apply<Op, S1, S2>
where Op: BitSetOp, S1: BitSetInterface, S2: BitSetInterface<Conf = S1::Conf>,

source§

impl<Op, S, Cache> BitSetInterface for &Reduce<Op, S, Cache>
where Op: BitSetOp, S: Iterator + Clone, S::Item: BitSetInterface, Cache: ReduceCache,

source§

impl<Op, S, Cache> BitSetInterface for Reduce<Op, S, Cache>
where Op: BitSetOp, S: Iterator + Clone, S::Item: BitSetInterface, Cache: ReduceCache,