Trait rayon::iter::ParallelExtend [−][src]
pub trait ParallelExtend<T> where
T: Send, { fn par_extend<I>(&mut self, par_iter: I)
where
I: IntoParallelIterator<Item = T>; }
Expand description
ParallelExtend
extends an existing collection with items from a ParallelIterator
.
Examples
Implementing ParallelExtend
for your type:
use rayon::prelude::*; use std::mem; struct BlackHole { mass: usize, } impl<T: Send> ParallelExtend<T> for BlackHole { fn par_extend<I>(&mut self, par_iter: I) where I: IntoParallelIterator<Item = T> { let par_iter = par_iter.into_par_iter(); self.mass += par_iter.count() * mem::size_of::<T>(); } } let mut bh = BlackHole { mass: 0 }; bh.par_extend(0i32..1000); assert_eq!(bh.mass, 4000); bh.par_extend(0i64..10); assert_eq!(bh.mass, 4080);
Required methods
fn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = T>,
[src]
fn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = T>,
[src]Extends an instance of the collection with the elements drawn
from the parallel iterator par_iter
.
Examples
use rayon::prelude::*; let mut vec = vec![]; vec.par_extend(0..5); vec.par_extend((0..5).into_par_iter().map(|i| i * i)); assert_eq!(vec, [0, 1, 2, 3, 4, 0, 1, 4, 9, 16]);
Implementations on Foreign Types
Extends a vector with items from a parallel iterator.
Extends a binary heap with items from a parallel iterator.
Extends a binary heap with copied items from a parallel iterator.
Extends a B-tree map with items from a parallel iterator.
Extends a B-tree map with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = (&'a K, &'a V)>,
[src]Extends a B-tree set with items from a parallel iterator.
Extends a B-tree set with copied items from a parallel iterator.
Extends a hash map with items from a parallel iterator.
Extends a hash map with copied items from a parallel iterator.
fn par_extend<I>(&mut self, par_iter: I) where
I: IntoParallelIterator<Item = (&'a K, &'a V)>,
[src]impl<T, S> ParallelExtend<T> for HashSet<T, S> where
T: Eq + Hash + Send,
S: BuildHasher + Send,
[src]
impl<T, S> ParallelExtend<T> for HashSet<T, S> where
T: Eq + Hash + Send,
S: BuildHasher + Send,
[src]Extends a hash set with items from a parallel iterator.
Extends a hash set with copied items from a parallel iterator.
Extends a linked list with items from a parallel iterator.
Extends a linked list with copied items from a parallel iterator.
Extends a string with characters from a parallel iterator.
Extends a string with copied characters from a parallel iterator.
Extends a string with string slices from a parallel iterator.
Extends a string with strings from a parallel iterator.
Extends a string with string slices from a parallel iterator.
Extends a deque with items from a parallel iterator.
Extends a deque with copied items from a parallel iterator.
Extends a vector with copied items from a parallel iterator.
Collapses all unit items from a parallel iterator into one.
impl<A, B, FromA, FromB> ParallelExtend<(A, B)> for (FromA, FromB) where
A: Send,
B: Send,
FromA: Send + ParallelExtend<A>,
FromB: Send + ParallelExtend<B>,
[src]
impl<A, B, FromA, FromB> ParallelExtend<(A, B)> for (FromA, FromB) where
A: Send,
B: Send,
FromA: Send + ParallelExtend<A>,
FromB: Send + ParallelExtend<B>,
[src]impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B) where
L: Send,
R: Send,
A: Send + ParallelExtend<L>,
B: Send + ParallelExtend<R>,
[src]
impl<L, R, A, B> ParallelExtend<Either<L, R>> for (A, B) where
L: Send,
R: Send,
A: Send + ParallelExtend<L>,
B: Send + ParallelExtend<R>,
[src]Implementors
impl<L, R, T> ParallelExtend<T> for Either<L, R> where
L: ParallelExtend<T>,
R: ParallelExtend<T>,
T: Send,
[src]
impl<L, R, T> ParallelExtend<T> for Either<L, R> where
L: ParallelExtend<T>,
R: ParallelExtend<T>,
T: Send,
[src]Either<L, R>
can be extended if both L
and R
are parallel extendable.