Trait ParIterUsing

Source
pub trait ParIterUsing<U, R = DefaultRunner>:
    Sized
    + Send
    + Sync
where R: ParallelRunner, U: Using,
{ type Item;
Show 30 methods // Required methods fn con_iter(&self) -> &impl ConcurrentIter; fn params(&self) -> Params; fn num_threads(self, num_threads: impl Into<NumThreads>) -> Self; fn chunk_size(self, chunk_size: impl Into<ChunkSize>) -> Self; fn iteration_order(self, collect: IterationOrder) -> Self; fn with_runner<Q: ParallelRunner>( self, ) -> impl ParIterUsing<U, Q, Item = Self::Item>; fn map<Out, Map>(self, map: Map) -> impl ParIterUsing<U, R, Item = Out> where Map: Fn(&mut U::Item, Self::Item) -> Out + Sync + Clone; fn filter<Filter>( self, filter: Filter, ) -> impl ParIterUsing<U, R, Item = Self::Item> where Filter: Fn(&mut U::Item, &Self::Item) -> bool + Sync + Clone; fn flat_map<IOut, FlatMap>( self, flat_map: FlatMap, ) -> impl ParIterUsing<U, R, Item = IOut::Item> where IOut: IntoIterator, FlatMap: Fn(&mut U::Item, Self::Item) -> IOut + Sync + Clone; fn filter_map<Out, FilterMap>( self, filter_map: FilterMap, ) -> impl ParIterUsing<U, R, Item = Out> where FilterMap: Fn(&mut U::Item, Self::Item) -> Option<Out> + Sync + Clone; fn collect_into<C>(self, output: C) -> C where C: ParCollectInto<Self::Item>; fn reduce<Reduce>(self, reduce: Reduce) -> Option<Self::Item> where Self::Item: Send, Reduce: Fn(&mut U::Item, Self::Item, Self::Item) -> Self::Item + Sync; fn first(self) -> Option<Self::Item> where Self::Item: Send; // Provided methods fn inspect<Operation>( self, operation: Operation, ) -> impl ParIterUsing<U, R, Item = Self::Item> where Operation: Fn(&mut U::Item, &Self::Item) + Sync + Clone { ... } fn copied<'a, T>(self) -> impl ParIterUsing<U, R, Item = T> where T: 'a + Copy, Self: ParIterUsing<U, R, Item = &'a T> { ... } fn cloned<'a, T>(self) -> impl ParIterUsing<U, R, Item = T> where T: 'a + Clone, Self: ParIterUsing<U, R, Item = &'a T> { ... } fn flatten( self, ) -> impl ParIterUsing<U, R, Item = <Self::Item as IntoIterator>::Item> where Self::Item: IntoIterator { ... } fn collect<C>(self) -> C where C: ParCollectInto<Self::Item> { ... } fn all<Predicate>(self, predicate: Predicate) -> bool where Self::Item: Send, Predicate: Fn(&mut U::Item, &Self::Item) -> bool + Sync + Clone { ... } fn any<Predicate>(self, predicate: Predicate) -> bool where Self::Item: Send, Predicate: Fn(&mut U::Item, &Self::Item) -> bool + Sync + Clone { ... } fn count(self) -> usize { ... } fn for_each<Operation>(self, operation: Operation) where Operation: Fn(&mut U::Item, Self::Item) + Sync { ... } fn max(self) -> Option<Self::Item> where Self::Item: Ord + Send { ... } fn max_by<Compare>(self, compare: Compare) -> Option<Self::Item> where Self::Item: Send, Compare: Fn(&Self::Item, &Self::Item) -> Ordering + Sync { ... } fn max_by_key<Key, GetKey>(self, key: GetKey) -> Option<Self::Item> where Self::Item: Send, Key: Ord, GetKey: Fn(&Self::Item) -> Key + Sync { ... } fn min(self) -> Option<Self::Item> where Self::Item: Ord + Send { ... } fn min_by<Compare>(self, compare: Compare) -> Option<Self::Item> where Self::Item: Send, Compare: Fn(&Self::Item, &Self::Item) -> Ordering + Sync { ... } fn min_by_key<Key, GetKey>(self, get_key: GetKey) -> Option<Self::Item> where Self::Item: Send, Key: Ord, GetKey: Fn(&Self::Item) -> Key + Sync { ... } fn sum<Out>(self) -> Out where Self::Item: Sum<Out>, Out: Send { ... } fn find<Predicate>(self, predicate: Predicate) -> Option<Self::Item> where Self::Item: Send, Predicate: Fn(&mut U::Item, &Self::Item) -> bool + Sync { ... }
}
Expand description

Parallel iterator which allows mutable access to a variable of type U within its iterator methods.

Note that one variable will be created per thread used by the parallel computation.

Required Associated Types§

Source

type Item

Element type of the parallel iterator.

Required Methods§

Source

fn con_iter(&self) -> &impl ConcurrentIter

Returns a reference to the input concurrent iterator.

Source

fn params(&self) -> Params

Parameters of the parallel iterator.

See crate::ParIter::params for details.

Source

fn num_threads(self, num_threads: impl Into<NumThreads>) -> Self

Sets the number of threads to be used in the parallel execution. Integers can be used as the argument with the following mapping:

  • 0 -> NumThreads::Auto

  • 1 -> NumThreads::sequential()

  • n > 0 -> NumThreads::Max(n)

    /// Parameters of the parallel iterator.

See crate::ParIter::num_threads for details.

Source

fn chunk_size(self, chunk_size: impl Into<ChunkSize>) -> Self

Sets the number of elements to be pulled from the concurrent iterator during the parallel execution. When integers are used as argument, the following mapping applies:

  • 0 -> ChunkSize::Auto
  • n > 0 -> ChunkSize::Exact(n)

Please use the default enum constructor for creating ChunkSize::Min variant.

See crate::ParIter::chunk_size for details.

Source

fn iteration_order(self, collect: IterationOrder) -> Self

Sets the iteration order of the parallel computation.

See crate::ParIter::iteration_order for details.

Source

fn with_runner<Q: ParallelRunner>( self, ) -> impl ParIterUsing<U, Q, Item = Self::Item>

Rather than the DefaultRunner, uses the parallel runner Q which implements ParallelRunner.

See crate::ParIter::with_runner for details.

Source

fn map<Out, Map>(self, map: Map) -> impl ParIterUsing<U, R, Item = Out>
where Map: Fn(&mut U::Item, Self::Item) -> Out + Sync + Clone,

Takes a closure map and creates a parallel iterator which calls that closure on each element.

Unlike crate::ParIter::map, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn filter<Filter>( self, filter: Filter, ) -> impl ParIterUsing<U, R, Item = Self::Item>
where Filter: Fn(&mut U::Item, &Self::Item) -> bool + Sync + Clone,

Creates an iterator which uses a closure filter to determine if an element should be yielded.

Unlike crate::ParIter::filter, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn flat_map<IOut, FlatMap>( self, flat_map: FlatMap, ) -> impl ParIterUsing<U, R, Item = IOut::Item>
where IOut: IntoIterator, FlatMap: Fn(&mut U::Item, Self::Item) -> IOut + Sync + Clone,

Creates an iterator that works like map, but flattens nested structure.

Unlike crate::ParIter::flat_map, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn filter_map<Out, FilterMap>( self, filter_map: FilterMap, ) -> impl ParIterUsing<U, R, Item = Out>
where FilterMap: Fn(&mut U::Item, Self::Item) -> Option<Out> + Sync + Clone,

Creates an iterator that both filters and maps.

The returned iterator yields only the values for which the supplied closure filter_map returns Some(value).

filter_map can be used to make chains of filter and map more concise. The example below shows how a map().filter().map() can be shortened to a single call to filter_map.

Unlike crate::ParIter::filter_map, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn collect_into<C>(self, output: C) -> C
where C: ParCollectInto<Self::Item>,

Collects all the items from an iterator into a collection.

Unlike crate::ParIter::collect_into, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn reduce<Reduce>(self, reduce: Reduce) -> Option<Self::Item>
where Self::Item: Send, Reduce: Fn(&mut U::Item, Self::Item, Self::Item) -> Self::Item + Sync,

Reduces the elements to a single one, by repeatedly applying a reducing operation.

See the details here: crate::ParIter::reduce.

Source

fn first(self) -> Option<Self::Item>
where Self::Item: Send,

Returns the first (or any) element of the iterator; returns None if it is empty.

  • first element is returned if default iteration order IterationOrder::Ordered is used,
  • any element is returned if IterationOrder::Arbitrary is set.

See the details here: crate::ParIter::first.

Provided Methods§

Source

fn inspect<Operation>( self, operation: Operation, ) -> impl ParIterUsing<U, R, Item = Self::Item>
where Operation: Fn(&mut U::Item, &Self::Item) + Sync + Clone,

Does something with each element of an iterator, passing the value on.

Unlike crate::ParIter::inspect, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn copied<'a, T>(self) -> impl ParIterUsing<U, R, Item = T>
where T: 'a + Copy, Self: ParIterUsing<U, R, Item = &'a T>,

Creates an iterator which copies all of its elements.

Unlike crate::ParIter::copied, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn cloned<'a, T>(self) -> impl ParIterUsing<U, R, Item = T>
where T: 'a + Clone, Self: ParIterUsing<U, R, Item = &'a T>,

Creates an iterator which clones all of its elements.

Unlike crate::ParIter::cloned, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn flatten( self, ) -> impl ParIterUsing<U, R, Item = <Self::Item as IntoIterator>::Item>
where Self::Item: IntoIterator,

Creates an iterator that flattens nested structure.

Unlike crate::ParIter::flatten, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn collect<C>(self) -> C
where C: ParCollectInto<Self::Item>,

Transforms an iterator into a collection.

Unlike crate::ParIter::collect, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn all<Predicate>(self, predicate: Predicate) -> bool
where Self::Item: Send, Predicate: Fn(&mut U::Item, &Self::Item) -> bool + Sync + Clone,

Tests if every element of the iterator matches a predicate.

Unlike crate::ParIter::all, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn any<Predicate>(self, predicate: Predicate) -> bool
where Self::Item: Send, Predicate: Fn(&mut U::Item, &Self::Item) -> bool + Sync + Clone,

Tests if any element of the iterator matches a predicate.

Unlike crate::ParIter::any, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn count(self) -> usize

Consumes the iterator, counting the number of iterations and returning it.

See the details here: crate::ParIter::count.

Source

fn for_each<Operation>(self, operation: Operation)
where Operation: Fn(&mut U::Item, Self::Item) + Sync,

Calls a closure on each element of an iterator.

Unlike crate::ParIter::for_each, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

Source

fn max(self) -> Option<Self::Item>
where Self::Item: Ord + Send,

Returns the maximum element of an iterator.

See the details here: crate::ParIter::max.

Source

fn max_by<Compare>(self, compare: Compare) -> Option<Self::Item>
where Self::Item: Send, Compare: Fn(&Self::Item, &Self::Item) -> Ordering + Sync,

Returns the element that gives the maximum value with respect to the specified compare function.

See the details here: crate::ParIter::max_by.

Source

fn max_by_key<Key, GetKey>(self, key: GetKey) -> Option<Self::Item>
where Self::Item: Send, Key: Ord, GetKey: Fn(&Self::Item) -> Key + Sync,

Returns the element that gives the maximum value from the specified function.

See the details here: crate::ParIter::max_by_key.

Source

fn min(self) -> Option<Self::Item>
where Self::Item: Ord + Send,

Returns the minimum element of an iterator.

See the details here: crate::ParIter::min.

Source

fn min_by<Compare>(self, compare: Compare) -> Option<Self::Item>
where Self::Item: Send, Compare: Fn(&Self::Item, &Self::Item) -> Ordering + Sync,

Returns the element that gives the minimum value with respect to the specified compare function.

See the details here: crate::ParIter::min_by.

Source

fn min_by_key<Key, GetKey>(self, get_key: GetKey) -> Option<Self::Item>
where Self::Item: Send, Key: Ord, GetKey: Fn(&Self::Item) -> Key + Sync,

Returns the element that gives the minimum value from the specified function.

See the details here: crate::ParIter::min_by_key.

Source

fn sum<Out>(self) -> Out
where Self::Item: Sum<Out>, Out: Send,

Sums the elements of an iterator.

See the details here: crate::ParIter::sum.

Source

fn find<Predicate>(self, predicate: Predicate) -> Option<Self::Item>
where Self::Item: Send, Predicate: Fn(&mut U::Item, &Self::Item) -> bool + Sync,

Searches for an element of an iterator that satisfies a predicate.

Unlike crate::ParIter::find, the closure allows access to mutable reference of the used variable.

Please see crate::ParIter::using transformation for details and examples.

Further documentation can be found here: using.md.

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.

Implementors§

Source§

impl<U, I, O, M1, R> ParIterUsing<U, R> for UParMap<U, I, O, M1, R>
where R: ParallelRunner, U: Using, I: ConcurrentIter, M1: Fn(&mut U::Item, I::Item) -> O + Sync,

Source§

type Item = O

Source§

impl<U, I, R> ParIterUsing<U, R> for UPar<U, I, R>

Source§

impl<U, I, Vo, M1, R> ParIterUsing<U, R> for UParXap<U, I, Vo, M1, R>
where R: ParallelRunner, U: Using, I: ConcurrentIter, Vo: Values, M1: Fn(&mut U::Item, I::Item) -> Vo + Sync,

Source§

type Item = <Vo as Values>::Item

Source§

impl<U, I, Vt, Vo, M1, F, M2, R> ParIterUsing<U, R> for UParXapFilterXap<U, I, Vt, Vo, M1, F, M2, R>
where R: ParallelRunner, U: Using, I: ConcurrentIter, Vt: Values, Vo: Values, M1: Fn(&mut U::Item, I::Item) -> Vt + Sync, F: Fn(&mut U::Item, &Vt::Item) -> bool + Sync, M2: Fn(&mut U::Item, Vt::Item) -> Vo + Sync,

Source§

type Item = <Vo as Values>::Item