Function split
fn split<D, S>(data: D, splitter: S) -> Split<D, S>
where
D: Send,
S: Fn(D) -> (D, Option<D>) + Sync
The split function takes arbitrary data and a closure that knows how to
split it, and turns this into a ParallelIterator.
Examples
As a simple example, Rayon can recursively split ranges of indices
use iter;
use *;
use Range;
// We define a range of indices as follows
type Range1D = ;
// Splitting it in two can be done like this
// By using iter::split, Rayon will split the range until it has enough work
// to feed the CPU cores, then give us the resulting sub-ranges
split.for_each;
This recursive splitting can be extended to two or three dimensions, to reproduce a classic "block-wise" parallelization scheme of graphics and numerical simulations:
# use iter;
# use *;
# use Range;
# type Range1D = ;
#
#
// A two-dimensional range of indices can be built out of two 1D ones
// We want to recursively split them by the largest dimension until we have
// enough sub-ranges to feed our mighty multi-core CPU. This function
// carries out one such split.
// Again, rayon can handle the recursive splitting for us
let range = Range2D ;
split.for_each;