[][src]Trait bevy_tasks::ParallelIterator

pub trait ParallelIterator<B> where
    B: Iterator<Item = Self::Item> + Send,
    Self: Sized + Send
{ type Item; pub fn next_batch(&mut self) -> Option<B>; pub fn size_hint(&self) -> (usize, Option<usize>) { ... }
pub fn count(self, pool: &TaskPool) -> usize { ... }
pub fn last(self, _pool: &TaskPool) -> Option<Self::Item> { ... }
pub fn nth(self, _pool: &TaskPool, n: usize) -> Option<Self::Item> { ... }
pub fn chain<U>(self, other: U) -> Chain<Self, U>
    where
        U: ParallelIterator<B, Item = Self::Item>
, { ... }
pub fn map<T, F>(self, f: F) -> Map<Self, F>
    where
        F: FnMut(Self::Item) -> T + Send + Clone
, { ... }
pub fn for_each<F>(self, pool: &TaskPool, f: F)
    where
        F: FnMut(Self::Item) + Send + Clone + Sync
, { ... }
pub fn filter<F>(self, predicate: F) -> Filter<Self, F>
    where
        F: FnMut(&Self::Item) -> bool
, { ... }
pub fn filter_map<R, F>(self, f: F) -> FilterMap<Self, F>
    where
        F: FnMut(Self::Item) -> Option<R>
, { ... }
pub fn flat_map<U, F>(self, f: F) -> FlatMap<Self, F>
    where
        F: FnMut(Self::Item) -> U,
        U: IntoIterator
, { ... }
pub fn flatten(self) -> Flatten<Self>
    where
        Self::Item: IntoIterator
, { ... }
pub fn fuse(self) -> Fuse<Self> { ... }
pub fn inspect<F>(self, f: F) -> Inspect<Self, F>
    where
        F: FnMut(&Self::Item)
, { ... }
pub fn by_ref(&mut self) -> &mut Self { ... }
pub fn collect<C>(self, pool: &TaskPool) -> C
    where
        C: FromIterator<Self::Item>,
        Self::Item: Send + 'static
, { ... }
pub fn partition<C, F>(self, pool: &TaskPool, f: F) -> (C, C)
    where
        C: Default + Extend<Self::Item> + Send,
        F: FnMut(&Self::Item) -> bool + Send + Sync + Clone,
        Self::Item: Send + 'static
, { ... }
pub fn fold<C, F, D>(self, pool: &TaskPool, init: C, f: F) -> Vec<C>
    where
        F: FnMut(C, Self::Item) -> C + Send + Sync + Clone,
        C: Clone + Send + Sync + 'static
, { ... }
pub fn all<F>(self, pool: &TaskPool, f: F) -> bool
    where
        F: FnMut(Self::Item) -> bool + Send + Sync + Clone
, { ... }
pub fn any<F>(self, pool: &TaskPool, f: F) -> bool
    where
        F: FnMut(Self::Item) -> bool + Send + Sync + Clone
, { ... }
pub fn position<F>(self, pool: &TaskPool, f: F) -> Option<usize>
    where
        F: FnMut(Self::Item) -> bool + Send + Sync + Clone
, { ... }
pub fn max(self, pool: &TaskPool) -> Option<Self::Item>
    where
        Self::Item: Ord + Send + 'static
, { ... }
pub fn min(self, pool: &TaskPool) -> Option<Self::Item>
    where
        Self::Item: Ord + Send + 'static
, { ... }
pub fn max_by_key<R, F>(self, pool: &TaskPool, f: F) -> Option<Self::Item>
    where
        R: Ord,
        F: FnMut(&Self::Item) -> R + Send + Sync + Clone,
        Self::Item: Send + 'static
, { ... }
pub fn max_by<F>(self, pool: &TaskPool, f: F) -> Option<Self::Item>
    where
        F: FnMut(&Self::Item, &Self::Item) -> Ordering + Send + Sync + Clone,
        Self::Item: Send + 'static
, { ... }
pub fn min_by_key<R, F>(self, pool: &TaskPool, f: F) -> Option<Self::Item>
    where
        R: Ord,
        F: FnMut(&Self::Item) -> R + Send + Sync + Clone,
        Self::Item: Send + 'static
, { ... }
pub fn min_by<F>(self, pool: &TaskPool, f: F) -> Option<Self::Item>
    where
        F: FnMut(&Self::Item, &Self::Item) -> Ordering + Send + Sync + Clone,
        Self::Item: Send + 'static
, { ... }
pub fn copied<'a, T>(self) -> Copied<Self>
    where
        Self: ParallelIterator<B, Item = &'a T>,
        T: 'a + Copy
, { ... }
pub fn cloned<'a, T>(self) -> Cloned<Self>
    where
        Self: ParallelIterator<B, Item = &'a T>,
        T: 'a + Copy
, { ... }
pub fn cycle(self) -> Cycle<Self>
    where
        Self: Clone
, { ... }
pub fn sum<S, R>(self, pool: &TaskPool) -> R
    where
        S: Sum<Self::Item> + Send + 'static,
        R: Sum<S>
, { ... }
pub fn product<S, R>(self, pool: &TaskPool) -> R
    where
        S: Product<Self::Item> + Send + 'static,
        R: Product<S>
, { ... } }

ParallelIterator closely emulates the std::iter::Iterator interface. However, it uses bevy_task to compute batches in parallel.

Note that the overhead of ParallelIterator is high relative to some workloads. In particular, if the batch size is too small or task being run in parallel is inexpensive, a ParallelIterator could take longer than a normal Iterator. Therefore, you should profile your code before using ParallelIterator.

Associated Types

Loading content...

Required methods

pub fn next_batch(&mut self) -> Option<B>[src]

Returns the next batch of items for processing.

Each batch is an iterator with items of the same type as the ParallelIterator. Returns None when there are no batches left.

Loading content...

Provided methods

pub fn size_hint(&self) -> (usize, Option<usize>)[src]

Returns the bounds on the remaining number of items in the parallel iterator.

See Iterator::size_hint()

pub fn count(self, pool: &TaskPool) -> usize[src]

Consumes the parallel iterator and returns the number of items.

See Iterator::count()

pub fn last(self, _pool: &TaskPool) -> Option<Self::Item>[src]

Consumes the parallel iterator and returns the last item.

See Iterator::last()

pub fn nth(self, _pool: &TaskPool, n: usize) -> Option<Self::Item>[src]

Consumes the parallel iterator and returns the nth item.

See Iterator::nth()

pub fn chain<U>(self, other: U) -> Chain<Self, U> where
    U: ParallelIterator<B, Item = Self::Item>, 
[src]

Takes two parallel iterators and returns a parallel iterators over both in sequence.

See Iterator::chain()

pub fn map<T, F>(self, f: F) -> Map<Self, F> where
    F: FnMut(Self::Item) -> T + Send + Clone
[src]

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

See Iterator::map()

pub fn for_each<F>(self, pool: &TaskPool, f: F) where
    F: FnMut(Self::Item) + Send + Clone + Sync
[src]

Calls a closure on each item of a parallel iterator.

See Iterator::for_each()

pub fn filter<F>(self, predicate: F) -> Filter<Self, F> where
    F: FnMut(&Self::Item) -> bool
[src]

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

See Iterator::filter()

pub fn filter_map<R, F>(self, f: F) -> FilterMap<Self, F> where
    F: FnMut(Self::Item) -> Option<R>, 
[src]

Creates a parallel iterator that both filters and maps.

See Iterator::filter_map()

pub fn flat_map<U, F>(self, f: F) -> FlatMap<Self, F> where
    F: FnMut(Self::Item) -> U,
    U: IntoIterator
[src]

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

See Iterator::flat_map()

pub fn flatten(self) -> Flatten<Self> where
    Self::Item: IntoIterator
[src]

Creates a parallel iterator that flattens nested structure.

See Iterator::flatten()

pub fn fuse(self) -> Fuse<Self>[src]

Creates a parallel iterator which ends after the first None.

See Iterator::fuse()

pub fn inspect<F>(self, f: F) -> Inspect<Self, F> where
    F: FnMut(&Self::Item), 
[src]

Does something with each item of a parallel iterator, passing the value on.

See Iterator::inspect()

pub fn by_ref(&mut self) -> &mut Self[src]

Borrows a parallel iterator, rather than consuming it.

See Iterator::by_ref()

pub fn collect<C>(self, pool: &TaskPool) -> C where
    C: FromIterator<Self::Item>,
    Self::Item: Send + 'static, 
[src]

Transforms a parallel iterator into a collection.

See Iterator::collect()

pub fn partition<C, F>(self, pool: &TaskPool, f: F) -> (C, C) where
    C: Default + Extend<Self::Item> + Send,
    F: FnMut(&Self::Item) -> bool + Send + Sync + Clone,
    Self::Item: Send + 'static, 
[src]

Consumes a parallel iterator, creating two collections from it.

See Iterator::partition()

pub fn fold<C, F, D>(self, pool: &TaskPool, init: C, f: F) -> Vec<C> where
    F: FnMut(C, Self::Item) -> C + Send + Sync + Clone,
    C: Clone + Send + Sync + 'static, 
[src]

Repeatedly applies a function to items of each batch of a parallel iterator, producing a Vec of final values.

Note that this folds each batch independently and returns a Vec of results (in batch order).

See Iterator::fold()

pub fn all<F>(self, pool: &TaskPool, f: F) -> bool where
    F: FnMut(Self::Item) -> bool + Send + Sync + Clone
[src]

Tests if every element of the parallel iterator matches a predicate.

Note that all is not short circuiting.

See Iterator::all()

pub fn any<F>(self, pool: &TaskPool, f: F) -> bool where
    F: FnMut(Self::Item) -> bool + Send + Sync + Clone
[src]

Tests if any element of the parallel iterator matches a predicate.

Note that any is not short circuiting.

See Iterator::any()

pub fn position<F>(self, pool: &TaskPool, f: F) -> Option<usize> where
    F: FnMut(Self::Item) -> bool + Send + Sync + Clone
[src]

Searches for an element in a parallel iterator, returning its index.

Note that position consumes the whole iterator.

See Iterator::position()

pub fn max(self, pool: &TaskPool) -> Option<Self::Item> where
    Self::Item: Ord + Send + 'static, 
[src]

Returns the maximum item of a parallel iterator.

See Iterator::max()

pub fn min(self, pool: &TaskPool) -> Option<Self::Item> where
    Self::Item: Ord + Send + 'static, 
[src]

Returns the minimum item of a parallel iterator.

See Iterator::min()

pub fn max_by_key<R, F>(self, pool: &TaskPool, f: F) -> Option<Self::Item> where
    R: Ord,
    F: FnMut(&Self::Item) -> R + Send + Sync + Clone,
    Self::Item: Send + 'static, 
[src]

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

See Iterator::max_by_key()

pub fn max_by<F>(self, pool: &TaskPool, f: F) -> Option<Self::Item> where
    F: FnMut(&Self::Item, &Self::Item) -> Ordering + Send + Sync + Clone,
    Self::Item: Send + 'static, 
[src]

Returns the item that gives the maximum value with respect to the specified comparison function.

See Iterator::max_by()

pub fn min_by_key<R, F>(self, pool: &TaskPool, f: F) -> Option<Self::Item> where
    R: Ord,
    F: FnMut(&Self::Item) -> R + Send + Sync + Clone,
    Self::Item: Send + 'static, 
[src]

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

See Iterator::min_by_key()

pub fn min_by<F>(self, pool: &TaskPool, f: F) -> Option<Self::Item> where
    F: FnMut(&Self::Item, &Self::Item) -> Ordering + Send + Sync + Clone,
    Self::Item: Send + 'static, 
[src]

Returns the item that gives the minimum value with respect to the specified comparison function.

See Iterator::min_by()

pub fn copied<'a, T>(self) -> Copied<Self> where
    Self: ParallelIterator<B, Item = &'a T>,
    T: 'a + Copy
[src]

Creates a parallel iterator which copies all of its items.

See Iterator::copied()

pub fn cloned<'a, T>(self) -> Cloned<Self> where
    Self: ParallelIterator<B, Item = &'a T>,
    T: 'a + Copy
[src]

Creates a parallel iterator which clones all of its items.

See Iterator::cloned()

pub fn cycle(self) -> Cycle<Self> where
    Self: Clone
[src]

Repeats a parallel iterator endlessly.

See Iterator::cycle()

pub fn sum<S, R>(self, pool: &TaskPool) -> R where
    S: Sum<Self::Item> + Send + 'static,
    R: Sum<S>, 
[src]

Sums the items of a parallel iterator.

See Iterator::sum()

pub fn product<S, R>(self, pool: &TaskPool) -> R where
    S: Product<Self::Item> + Send + 'static,
    R: Product<S>, 
[src]

Multiplies all the items of a parallel iterator.

See Iterator::product()

Loading content...

Implementors

Loading content...