Trait ph::fmph::keyset::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.

Object Safety§

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>