Skip to main content

ImmutableSlice

Struct ImmutableSlice 

Source
pub struct ImmutableSlice<'k, K> { /* private fields */ }
Expand description

Implements KeySet that use immutable slice.

It does not use any index for pointing remain keys. That is why it is recommended to use it with CachedKeySet.

Implementations§

Source§

impl<'k, K: Sync> ImmutableSlice<'k, K>

Source

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

Source

pub fn cached( slice: &[K], clone_threshold: usize, ) -> CachedKeySet<K, ImmutableSlice<'_, K>>

Trait Implementations§

Source§

impl<'k, K: Sync + Send + Clone> KeySet<K> for ImmutableSlice<'k, K>

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 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 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 retain_keys<F, P, R>( &mut self, _filter: F, _retained_earlier: P, remove_count: R, )
where R: FnMut() -> usize,

Retains in self keys pointed by the filter and remove the rest, using single thread. Read more
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 + Sync + Send,

Multi-threaded version of map_each_key.
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 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 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 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 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).
Source§

fn into_vec<P>(self, retained_hint: P) -> Vec<K>
where P: FnMut(&K) -> bool, K: Clone, Self: Sized,

Convert self into the vector of retained keys. Read more
Source§

fn par_into_vec<P>(self, retained_hint: P) -> Vec<K>
where P: Fn(&K) -> bool + Sync + Send, Self: Sized, K: Clone + Send,

Multi-threaded version of into_vec.

Auto Trait Implementations§

§

impl<'k, K> Freeze for ImmutableSlice<'k, K>

§

impl<'k, K> RefUnwindSafe for ImmutableSlice<'k, K>
where K: RefUnwindSafe,

§

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

§

impl<'k, K> Sync for ImmutableSlice<'k, K>
where K: Sync,

§

impl<'k, K> Unpin for ImmutableSlice<'k, K>

§

impl<'k, K> UnsafeUnpin for ImmutableSlice<'k, K>

§

impl<'k, K> UnwindSafe for ImmutableSlice<'k, K>
where K: RefUnwindSafe,

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> CastableFrom<T> for T

Source§

fn cast_from(value: T) -> T

Call Self as W
Source§

impl<T, U> CastableInto<U> for T
where U: CastableFrom<T>,

Source§

fn cast(self) -> U

Call W::cast_from(self)
Source§

impl<T> DowncastableFrom<T> for T

Source§

fn downcast_from(value: T) -> T

Truncate the current UnsignedInt to a possibly smaller size
Source§

impl<T, U> DowncastableInto<U> for T
where U: DowncastableFrom<T>,

Source§

fn downcast(self) -> U

Call W::downcast_from(self)
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Splat<T> for T

Source§

fn splat(value: T) -> T

Source§

impl<T> To<T> for T

Source§

fn to(self) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
Source§

impl<T> UpcastableFrom<T> for T

Source§

fn upcast_from(value: T) -> T

Extend the current UnsignedInt to a possibly bigger size.
Source§

impl<T, U> UpcastableInto<U> for T
where U: UpcastableFrom<T>,

Source§

fn upcast(self) -> U

Call W::upcast_from(self)
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V