pub struct SliceSourceWithRefs<'k, K, I: RefsIndex = u8> { /* private fields */ }
Expand description

KeySet implementation that stores reference to slice with keys, and indices of this slice that points retained keys. Indices are stored partitioned to segments and stored as 8 (if I=u8) or 16-bit (if I=u16) integers. Each segment covers $2^8$ or $2^{16}$ consecutive keys. Empty segments are not stored.

Implementations§

source§

impl<'k, K: Sync + 'k, I: RefsIndex + Send + Sync> SliceSourceWithRefs<'k, K, I>

source

pub fn new(slice: &'k [K]) -> Self

Trait Implementations§

source§

impl<'k, K: Sync, I: RefsIndex + Sync + Send> KeySet<K> for SliceSourceWithRefs<'k, K, I>

source§

fn keys_len(&self) -> usize

Returns number of retained keys. Guarantee to be very fast.
source§

fn has_par_for_each_key(&self) -> bool

Returns true only if Self::par_for_each_key can use multiple threads.
source§

fn for_each_key<F, P>(&self, f: F, _retained_hint: P)
where F: FnMut(&K), P: FnMut(&K) -> bool,

Call f for each key in the set, using single thread. Read more
source§

fn par_for_each_key<F, P>(&self, f: F, _retained_hint: P)
where F: Fn(&K) + Sync + Send, P: Fn(&K) -> bool + Sync + Send,

Multi-threaded version of for_each_key.
source§

fn par_map_each_key<R, M, P>(&self, map: M, _retained_hint: P) -> Vec<R>
where M: Fn(&K) -> R + Sync + Send, R: Send, P: Fn(&K) -> bool,

Multi-threaded version of map_each_key.
source§

fn retain_keys<F, P, R>( &mut self, filter: F, _retained_earlier: P, remove_count: R )
where F: FnMut(&K) -> bool, P: FnMut(&K) -> bool, R: FnMut() -> usize,

Retains in self keys pointed by the filter and remove the rest, using single thread. Read more
source§

fn par_retain_keys<F, P, R>( &mut self, filter: F, _retained_earlier: P, remove_count: R )
where F: Fn(&K) -> bool + Sync + Send, P: Fn(&K) -> bool + Sync + Send, R: Fn() -> usize,

Multi-threaded version of retain_keys.
source§

fn retain_keys_with_indices<IF, F, P, R>( &mut self, index_filter: IF, _filter: F, retained_earlier: P, remove_count: R )
where IF: FnMut(usize) -> bool, F: FnMut(&K) -> bool, P: FnMut(&K) -> bool, R: FnMut() -> usize,

Retains in self keys pointed by the index_filter (or filter if self does not support index_filter) and remove the rest. Uses single thread. Read more
source§

fn par_retain_keys_with_indices<IF, F, P, R>( &mut self, index_filter: IF, _filter: F, _retained_earlier: P, remove_count: R )
where IF: Fn(usize) -> bool + Sync + Send, F: Fn(&K) -> bool + Sync + Send, P: Fn(&K) -> bool + Sync + Send, R: Fn() -> usize,

Multi-threaded version of retain_keys_with_indices.
source§

fn map_each_key<R, M, P>(&self, map: M, retained_hint: P) -> Vec<R>
where M: FnMut(&K) -> R, P: FnMut(&K) -> bool,

Calls map for each key in the set, and returns outputs of these calls. Uses single thread. Read more
source§

fn maybe_par_map_each_key<R, M, P>( &self, map: M, retained_hint: P, use_mt: bool ) -> Vec<R>
where M: Fn(&K) -> R + Sync + Send, R: Send, P: Fn(&K) -> bool + Sync + Send,

Calls either map_each_key (if use_mt is false) or par_map_each_key (if use_mt is true).
source§

fn maybe_par_retain_keys<F, P, R>( &mut self, filter: F, retained_earlier: P, remove_count: R, use_mt: bool )
where F: Fn(&K) -> bool + Sync + Send, P: Fn(&K) -> bool + Sync + Send, R: Fn() -> usize,

Calls either retain_keys (if use_mt is false) or par_retain_keys (if use_mt is true).
source§

fn maybe_par_retain_keys_with_indices<IF, F, P, R>( &mut self, index_filter: IF, filter: F, retained_earlier: P, remove_count: R, use_mt: bool )
where IF: Fn(usize) -> bool + Sync + Send, F: Fn(&K) -> bool + Sync + Send, P: Fn(&K) -> bool + Sync + Send, R: Fn() -> usize,

Calls either retain_keys_with_indices (if use_mt is false) or par_retain_keys_with_indices (if use_mt is true).

Auto Trait Implementations§

§

impl<'k, K, I> RefUnwindSafe for SliceSourceWithRefs<'k, K, I>

§

impl<'k, K, I> Send for SliceSourceWithRefs<'k, K, I>
where I: Send, K: Sync,

§

impl<'k, K, I> Sync for SliceSourceWithRefs<'k, K, I>
where I: Sync, K: Sync,

§

impl<'k, K, I> Unpin for SliceSourceWithRefs<'k, K, I>
where I: Unpin,

§

impl<'k, K, I> UnwindSafe for SliceSourceWithRefs<'k, K, I>

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.