pub trait ParIterUsing<U, R = DefaultRunner>:
Sized
+ Send
+ Syncwhere
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§
Required Methods§
Sourcefn con_iter(&self) -> &impl ConcurrentIter
fn con_iter(&self) -> &impl ConcurrentIter
Returns a reference to the input concurrent iterator.
Sourcefn params(&self) -> Params
fn params(&self) -> Params
Parameters of the parallel iterator.
See crate::ParIter::params for details.
Sourcefn num_threads(self, num_threads: impl Into<NumThreads>) -> Self
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.
Sourcefn chunk_size(self, chunk_size: impl Into<ChunkSize>) -> Self
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.
Sourcefn iteration_order(self, collect: IterationOrder) -> Self
fn iteration_order(self, collect: IterationOrder) -> Self
Sets the iteration order of the parallel computation.
See crate::ParIter::iteration_order for details.
Sourcefn with_runner<Q: ParallelRunner>(
self,
) -> impl ParIterUsing<U, Q, Item = Self::Item>
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.
Sourcefn map<Out, Map>(self, map: Map) -> impl ParIterUsing<U, R, Item = Out>
fn map<Out, Map>(self, map: Map) -> impl ParIterUsing<U, R, Item = Out>
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
.
Sourcefn filter<Filter>(
self,
filter: Filter,
) -> impl ParIterUsing<U, R, Item = Self::Item>
fn filter<Filter>( self, filter: Filter, ) -> impl ParIterUsing<U, R, Item = Self::Item>
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
.
Sourcefn flat_map<IOut, FlatMap>(
self,
flat_map: FlatMap,
) -> impl ParIterUsing<U, R, Item = IOut::Item>
fn flat_map<IOut, FlatMap>( self, flat_map: FlatMap, ) -> impl ParIterUsing<U, R, Item = IOut::Item>
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
.
Sourcefn filter_map<Out, FilterMap>(
self,
filter_map: FilterMap,
) -> impl ParIterUsing<U, R, Item = Out>
fn filter_map<Out, FilterMap>( self, filter_map: FilterMap, ) -> impl ParIterUsing<U, R, Item = Out>
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
.
Sourcefn collect_into<C>(self, output: C) -> Cwhere
C: ParCollectInto<Self::Item>,
fn collect_into<C>(self, output: C) -> Cwhere
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
.
Sourcefn reduce<Reduce>(self, reduce: Reduce) -> Option<Self::Item>
fn reduce<Reduce>(self, reduce: Reduce) -> Option<Self::Item>
Reduces the elements to a single one, by repeatedly applying a reducing operation.
See the details here: crate::ParIter::reduce.
Sourcefn first(self) -> Option<Self::Item>
fn first(self) -> Option<Self::Item>
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§
Sourcefn inspect<Operation>(
self,
operation: Operation,
) -> impl ParIterUsing<U, R, Item = Self::Item>
fn inspect<Operation>( self, operation: Operation, ) -> impl ParIterUsing<U, R, Item = Self::Item>
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
.
Sourcefn copied<'a, T>(self) -> impl ParIterUsing<U, R, Item = T>
fn copied<'a, T>(self) -> impl ParIterUsing<U, R, Item = 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
.
Sourcefn cloned<'a, T>(self) -> impl ParIterUsing<U, R, Item = T>
fn cloned<'a, T>(self) -> impl ParIterUsing<U, R, Item = 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
.
Sourcefn flatten(
self,
) -> impl ParIterUsing<U, R, Item = <Self::Item as IntoIterator>::Item>where
Self::Item: IntoIterator,
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
.
Sourcefn collect<C>(self) -> Cwhere
C: ParCollectInto<Self::Item>,
fn collect<C>(self) -> Cwhere
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
.
Sourcefn all<Predicate>(self, predicate: Predicate) -> bool
fn all<Predicate>(self, predicate: Predicate) -> bool
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
.
Sourcefn any<Predicate>(self, predicate: Predicate) -> bool
fn any<Predicate>(self, predicate: Predicate) -> bool
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
.
Sourcefn count(self) -> usize
fn count(self) -> usize
Consumes the iterator, counting the number of iterations and returning it.
See the details here: crate::ParIter::count.
Sourcefn for_each<Operation>(self, operation: Operation)
fn for_each<Operation>(self, operation: Operation)
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
.
Sourcefn max(self) -> Option<Self::Item>
fn max(self) -> Option<Self::Item>
Returns the maximum element of an iterator.
See the details here: crate::ParIter::max.
Sourcefn max_by<Compare>(self, compare: Compare) -> Option<Self::Item>
fn max_by<Compare>(self, compare: Compare) -> Option<Self::Item>
Returns the element that gives the maximum value with respect to the specified compare
function.
See the details here: crate::ParIter::max_by.
Sourcefn max_by_key<Key, GetKey>(self, key: GetKey) -> Option<Self::Item>
fn max_by_key<Key, GetKey>(self, key: GetKey) -> Option<Self::Item>
Returns the element that gives the maximum value from the specified function.
See the details here: crate::ParIter::max_by_key.
Sourcefn min(self) -> Option<Self::Item>
fn min(self) -> Option<Self::Item>
Returns the minimum element of an iterator.
See the details here: crate::ParIter::min.
Sourcefn min_by<Compare>(self, compare: Compare) -> Option<Self::Item>
fn min_by<Compare>(self, compare: Compare) -> Option<Self::Item>
Returns the element that gives the minimum value with respect to the specified compare
function.
See the details here: crate::ParIter::min_by.
Sourcefn min_by_key<Key, GetKey>(self, get_key: GetKey) -> Option<Self::Item>
fn min_by_key<Key, GetKey>(self, get_key: GetKey) -> Option<Self::Item>
Returns the element that gives the minimum value from the specified function.
See the details here: crate::ParIter::min_by_key.
Sourcefn sum<Out>(self) -> Out
fn sum<Out>(self) -> Out
Sums the elements of an iterator.
See the details here: crate::ParIter::sum.
Sourcefn find<Predicate>(self, predicate: Predicate) -> Option<Self::Item>
fn find<Predicate>(self, predicate: Predicate) -> Option<Self::Item>
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.