Skip to main content

KeySet

Trait KeySet 

Source
pub trait KeySet<K> {
Show 15 methods // Required methods fn keys_len(&self) -> usize; fn for_each_key<F, P>(&self, f: F, retained_hint: P) where F: FnMut(&K), P: FnMut(&K) -> bool; 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; // Provided methods fn has_par_for_each_key(&self) -> bool { ... } 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 { ... } fn map_each_key<R, M, P>(&self, map: M, retained_hint: P) -> Vec<R> where M: FnMut(&K) -> R, P: FnMut(&K) -> bool { ... } 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 { ... } 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 { ... } 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 { ... } 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 { ... } 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 { ... } 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 { ... } 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 { ... } fn into_vec<P>(self, retained_hint: P) -> Vec<K> where P: FnMut(&K) -> bool, K: Clone, Self: Sized { ... } fn par_into_vec<P>(self, retained_hint: P) -> Vec<K> where P: Fn(&K) -> bool + Sync + Send, Self: Sized, K: Clone + Send { ... }
}
Expand description

A trait for accessing and managing sets of keys (of the type K) during construction of fmph::Function or fmph::GOFunction.

Required Methods§

Source

fn keys_len(&self) -> usize

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

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.

If self doesn’t remember which keys are retained it uses retained_hint to check this.

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.

  • filter shows the keys to be retained (the result of the function can be unspecified for keys removed earlier),
  • retained_earlier shows the keys that have not been removed earlier,
  • remove_count returns number of keys to remove.

Provided Methods§

Source

fn has_par_for_each_key(&self) -> bool

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

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

If self doesn’t remember which keys are retained it uses retained_hint to check this.

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.

  • index_filter shows indices (consistent with par_map_each_key) of keys to be retained,
  • filter shows the keys to be retained,
  • retained_earlier shows the keys that have not been removed earlier,
  • remove_count returns number of keys to remove.

The results of index_filter and filter are unspecified for keys removed earlier.

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.

If self doesn’t remember which keys are retained it uses retained_hint to check this.

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<K: Sync + Send> KeySet<K> for Vec<K>

Source§

fn keys_len(&self) -> usize

Source§

fn has_par_for_each_key(&self) -> bool

Source§

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

Source§

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

Source§

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

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,

Source§

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

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, R: Fn() -> usize,

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,

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, R: Fn() -> usize,

Source§

fn into_vec<P>(self, _retained_hint: P) -> Vec<K>

Source§

fn par_into_vec<P>(self, _retained_hint: P) -> Vec<K>

Implementors§

Source§

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

Source§

impl<'k, K: Sync> KeySet<K> for SliceMutSource<'k, K>

Source§

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

Source§

impl<GetKeyIter: GetIterator> KeySet<<GetKeyIter as GetIterator>::Item> for DynamicKeySet<GetKeyIter>
where GetKeyIter::Item: Send,

Source§

impl<K: Clone + Sync + Send, KS: KeySet<K>> KeySet<K> for CachedKeySet<K, KS>