[][src]Trait asparit::ParallelDrainFull

pub trait ParallelDrainFull<'a> {
    type Iter: ParallelIterator<'a, Item = Self::Item>;
    type Item: Send + 'a;
    pub fn par_drain(self) -> Self::Iter;
}

ParallelDrainFull creates a parallel iterator that moves all items from a collection while retaining the original capacity.

Types which are indexable typically implement ParallelDrainRange instead, where you can drain fully with par_drain(..).

Associated Types

type Iter: ParallelIterator<'a, Item = Self::Item>

The draining parallel iterator type that will be created.

type Item: Send + 'a

The type of item that the parallel iterator will produce. This is usually the same as IntoParallelIterator::Item.

Loading content...

Required methods

pub fn par_drain(self) -> Self::Iter

Returns a draining parallel iterator over an entire collection.

When the iterator is dropped, all items are removed, even if the iterator was not fully consumed. If the iterator is leaked, for example using std::mem::forget, it is unspecified how many items are removed.

Examples

use asparit::*;
use std::collections::{BinaryHeap, HashSet};

let squares: HashSet<i32> = (0..10).map(|x| x * x).collect();

let mut heap: BinaryHeap<_> = squares.iter().copied().collect();
assert_eq!(
    // heaps are drained in arbitrary order
    heap.par_drain()
        .inspect(|x| assert!(squares.contains(x)))
        .count()
        .exec(),
    squares.len(),
);
assert!(heap.is_empty());
assert!(heap.capacity() >= squares.len());
Loading content...

Implementations on Foreign Types

impl<'a, I> ParallelDrainFull<'a> for &'a mut BinaryHeap<I> where
    I: Send + 'a, 
[src]

type Iter = <Vec<I> as IntoParallelIterator<'a>>::Iter

type Item = I

impl<'a, I, S> ParallelDrainFull<'a> for &'a mut HashSet<I, S> where
    I: Send + 'a,
    S: BuildHasher
[src]

type Iter = <Vec<I> as IntoParallelIterator<'a>>::Iter

type Item = I

Loading content...

Implementors

Loading content...