Trait ParallelSlice
trait ParallelSlice<T: Sync>
Parallel extensions for slices.
Required Methods
fn as_parallel_slice(self: &Self) -> &[T]Returns a plain slice, which is used to implement the rest of the parallel methods.
Provided Methods
fn par_split<P>(self: &Self, separator: P) -> Split<'_, T, P> where P: Fn(&T) -> bool + Sync + SendReturns a parallel iterator over subslices separated by elements that match the separator.
Examples
use *; let products: = .par_split .map .collect; assert_eq!;fn par_split_inclusive<P>(self: &Self, separator: P) -> SplitInclusive<'_, T, P> where P: Fn(&T) -> bool + Sync + SendReturns a parallel iterator over subslices separated by elements that match the separator, including the matched part as a terminator.
Examples
use *; let lengths: = .par_split_inclusive .map .collect; assert_eq!;fn par_windows(self: &Self, window_size: usize) -> Windows<'_, T>Returns a parallel iterator over all contiguous windows of length
window_size. The windows overlap.Examples
use *; let windows: = .par_windows.collect; assert_eq!;fn par_chunks(self: &Self, chunk_size: usize) -> Chunks<'_, T>Returns a parallel iterator over at most
chunk_sizeelements ofselfat a time. The chunks do not overlap.If the number of elements in the iterator is not divisible by
chunk_size, the last chunk may be shorter thanchunk_size. All other chunks will have that exact length.Examples
use *; let chunks: = .par_chunks.collect; assert_eq!;fn par_chunks_exact(self: &Self, chunk_size: usize) -> ChunksExact<'_, T>Returns a parallel iterator over
chunk_sizeelements ofselfat a time. The chunks do not overlap.If
chunk_sizedoes not divide the length of the slice, then the last up tochunk_size-1elements will be omitted and can be retrieved from the remainder function of the iterator.Examples
use *; let chunks: = .par_chunks_exact.collect; assert_eq!;fn par_rchunks(self: &Self, chunk_size: usize) -> RChunks<'_, T>Returns a parallel iterator over at most
chunk_sizeelements ofselfat a time, starting at the end. The chunks do not overlap.If the number of elements in the iterator is not divisible by
chunk_size, the last chunk may be shorter thanchunk_size. All other chunks will have that exact length.Examples
use *; let chunks: = .par_rchunks.collect; assert_eq!;fn par_rchunks_exact(self: &Self, chunk_size: usize) -> RChunksExact<'_, T>Returns a parallel iterator over
chunk_sizeelements ofselfat a time, starting at the end. The chunks do not overlap.If
chunk_sizedoes not divide the length of the slice, then the last up tochunk_size-1elements will be omitted and can be retrieved from the remainder function of the iterator.Examples
use *; let chunks: = .par_rchunks_exact.collect; assert_eq!;fn par_chunk_by<F>(self: &Self, pred: F) -> ChunkBy<'_, T, F> where F: Fn(&T, &T) -> bool + Send + SyncReturns a parallel iterator over the slice producing non-overlapping runs of elements using the predicate to separate them.
The predicate is called on two elements following themselves, it means the predicate is called on
slice[0]andslice[1]then onslice[1]andslice[2]and so on.Examples
use *; let chunks: = .par_chunk_by.collect; assert_eq!; assert_eq!; assert_eq!;
Implementors
impl<T: Sync> ParallelSlice for [T]