usesuper::plumbing::*; usesuper::*; use std::sync::atomic::{AtomicUsize, Ordering};
/// `TakeAny` is an iterator that iterates over `n` elements from anywhere in `I`. /// This struct is created by the [`take_any()`] method on [`ParallelIterator`] /// /// [`take_any()`]: trait.ParallelIterator.html#method.take_any /// [`ParallelIterator`]: trait.ParallelIterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Clone, Debug)] pubstruct TakeAny<I: ParallelIterator> {
base: I,
count: usize,
}
impl<I> TakeAny<I> where
I: ParallelIterator,
{ /// Creates a new `TakeAny` iterator. pub(super) fn new(base: I, count: usize) -> Self {
TakeAny { base, count }
}
}
impl<I> ParallelIterator for TakeAny<I> where
I: ParallelIterator,
{ type Item = I::Item;
fn drive_unindexed<C>(self, consumer: C) -> C::Result where
C: UnindexedConsumer<Self::Item>,
{ let consumer1 = TakeAnyConsumer {
base: consumer,
count: &AtomicUsize::new(self.count),
}; self.base.drive_unindexed(consumer1)
}
}
impl<'f, T, C> Consumer<T> for TakeAnyConsumer<'f, C> where
C: Consumer<T>,
T: Send,
{ type Folder = TakeAnyFolder<'f, C::Folder>; type Reducer = C::Reducer; type Result = C::Result;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.