GenericIterator

Enum GenericIterator 

Source
pub enum GenericIterator<T, S, R, O>
where T: Send + Sync, S: Iterator<Item = T>, R: ParallelIterator<Item = T>, O: ParIter<Item = T>,
{ Sequential(S), Rayon(R), Orx(O), }
Expand description

An iterator that generalizes over:

  • sequential iterators,
  • rayon’s parallel iterators, and
  • orx-parallel’s parallel iterators.

This is particularly useful for enabling a convenient way to run experiments using these different computation approaches.

Variants§

§

Sequential(S)

Sequential, or regular, iterator.

§

Rayon(R)

rayon’s parallel iterator.

§

Orx(O)

orx-parallel’s parallel iterator.

Implementations§

Source§

impl<T, S, R, O> GenericIterator<T, S, R, O>
where T: Send + Sync, S: Iterator<Item = T>, R: ParallelIterator<Item = T>, O: ParIter<Item = T>,

Source

pub fn collect_vec(self) -> Vec<T>

Collects the elements of the iterator into a vector.

See collect for details of the general collect method.

Source§

impl<T, S, R, O> GenericIterator<T, S, R, O>
where T: Send + Sync, S: Iterator<Item = T>, R: ParallelIterator<Item = T>, O: ParIter<Item = T>,

Source

pub fn find<Predicate>(self, predicate: Predicate) -> Option<T>
where Predicate: Fn(&T) -> bool + Send + Sync + Clone,

Find computation for the generic iterator.

See find for details.

Source

pub fn find_any<Predicate>(self, predicate: Predicate) -> Option<T>
where Predicate: Fn(&T) -> bool + Send + Sync + Clone,

Find-any computation for the generic iterator.

See first for details.

Source§

impl<T, S> GenericIterator<T, S, Empty<T>, ParEmpty<T>>
where T: Send + Sync, S: Iterator<Item = T>,

Source

pub fn sequential(iter: S) -> Self

Creates the generic iterator from sequential iterator variant.

Source§

impl<T, R> GenericIterator<T, Empty<T>, R, ParEmpty<T>>
where T: Send + Sync, R: ParallelIterator<Item = T>,

Source

pub fn rayon(iter: R) -> Self

Creates the generic iterator from rayon iterator variant.

Source§

impl<T, O> GenericIterator<T, Empty<T>, Empty<T>, O>
where T: Send + Sync, O: ParIter<Item = T>,

Source

pub fn orx(iter: O) -> Self

Creates the generic iterator from orx-parallel iterator variant.

Source§

impl<T, S, R, O> GenericIterator<T, S, R, O>
where T: Send + Sync, S: Iterator<Item = T>, R: ParallelIterator<Item = T>, O: ParIter<Item = T>,

Source

pub fn reduce<Reduce>(self, reduce: Reduce) -> Option<T>
where Reduce: Fn(T, T) -> T + Send + Sync,

Reduction for the generic iterator.

See reduce for details.

Source

pub fn count(self) -> usize

Count reduction for the generic iterator.

See count for details.

Source

pub fn for_each<Operation>(self, operation: Operation)
where Operation: Fn(T) + Sync + Send,

For-each iteration for the generic iterator.

See for_each for details.

Source

pub fn max(self) -> Option<T>
where T: Ord,

Max reduction for the generic iterator.

See max for details.

Source

pub fn max_by<Compare>(self, compare: Compare) -> Option<T>
where Compare: Fn(&T, &T) -> Ordering + Sync + Send,

Max-by reduction for the generic iterator.

See max_by for details.

Source

pub fn max_by_key<Key, GetKey>(self, key: GetKey) -> Option<T>
where Key: Ord + Send, GetKey: Fn(&T) -> Key + Sync + Send,

Max-by-key reduction for the generic iterator.

See max_by_key for details.

Source

pub fn min(self) -> Option<T>
where T: Ord,

Min reduction for the generic iterator.

See min for details.

Source

pub fn min_by<Compare>(self, compare: Compare) -> Option<T>
where Compare: Fn(&T, &T) -> Ordering + Sync + Send,

Min-by reduction for the generic iterator.

See min_by for details.

Source

pub fn min_by_key<Key, GetKey>(self, key: GetKey) -> Option<T>
where Key: Ord + Send, GetKey: Fn(&T) -> Key + Sync + Send,

Min-by-key reduction for the generic iterator.

See min_by_key for details.

Source

pub fn sum(self) -> T
where T: Sum<T> + Sum<T>,

Sum reduction for the generic iterator.

See sum for details.

Source§

impl<T, S, R, O> GenericIterator<T, S, R, O>
where T: Send + Sync, S: Iterator<Item = T>, R: ParallelIterator<Item = T>, O: ParIter<Item = T>,

Source

pub fn map<Out, Map>( self, map: Map, ) -> GenericIterator<Out, impl Iterator<Item = Out>, impl ParallelIterator<Item = Out>, impl ParIter<Item = Out>>
where Out: Send + Sync, Map: Fn(T) -> Out + Send + Sync + Clone,

Map transformation for the generic iterator.

See map for details.

Source

pub fn filter<Filter>( self, filter: Filter, ) -> GenericIterator<T, impl Iterator<Item = T>, impl ParallelIterator<Item = T>, impl ParIter<Item = T>>
where Filter: Fn(&T) -> bool + Send + Sync + Clone,

Filter transformation for the generic iterator.

See filter for details.

Source

pub fn flat_map<IOut, FlatMap>( self, flat_map: FlatMap, ) -> GenericIterator<<IOut as IntoIterator>::Item, impl Iterator<Item = <IOut as IntoIterator>::Item>, impl ParallelIterator<Item = <IOut as IntoIterator>::Item>, impl ParIter<Item = <IOut as IntoIterator>::Item>>
where IOut: IntoIterator + Send + Sync + IntoParallelIterator<Item = <IOut as IntoIterator>::Item>, <IOut as IntoIterator>::IntoIter: Send + Sync, <IOut as IntoIterator>::Item: Send + Sync, FlatMap: Fn(T) -> IOut + Send + Sync + Clone,

Flat-map transformation for the generic iterator.

See flat_map for details.

Source

pub fn filter_map<Out, FilterMap>( self, filter_map: FilterMap, ) -> GenericIterator<Out, impl Iterator<Item = Out>, impl ParallelIterator<Item = Out>, impl ParIter<Item = Out>>
where Out: Send + Sync, FilterMap: Fn(T) -> Option<Out> + Send + Sync + Clone,

Filter-map transformation for the generic iterator.

See filter_map for details.

Source

pub fn inspect<Operation>( self, operation: Operation, ) -> GenericIterator<T, impl Iterator<Item = T>, impl ParallelIterator<Item = T>, impl ParIter<Item = T>>
where Operation: Fn(&T) + Sync + Send + Clone,

Inspect transformation for the generic iterator.

See inspect for details.

Source

pub fn flatten( self, ) -> GenericIterator<<T as IntoIterator>::Item, impl Iterator<Item = <T as IntoIterator>::Item>, impl ParallelIterator<Item = <T as IntoIterator>::Item>, impl ParIter<Item = <T as IntoIterator>::Item>>
where T: IntoIterator + IntoParallelIterator<Item = <T as IntoIterator>::Item>, <T as IntoIterator>::IntoIter: Send + Sync, <T as IntoIterator>::Item: Send + Sync, R: Send + Sync, Self: Send + Sync,

Flatten transformation for the generic iterator.

See flatten for details.

Source§

impl<'a, T, S, R, O> GenericIterator<&'a T, S, R, O>
where &'a T: Send + Sync, S: Iterator<Item = &'a T>, R: ParallelIterator<Item = &'a T>, O: ParIter<Item = &'a T>,

Source

pub fn copied( self, ) -> GenericIterator<T, impl Iterator<Item = T> + use<'a, T, S, R, O>, impl ParallelIterator<Item = T> + use<'a, T, S, R, O>, impl ParIter<Item = T> + use<'a, T, S, R, O>>
where T: Copy + Send + Sync + 'a,

Copied transformation for the generic iterator.

See copied for details.

Source

pub fn cloned( self, ) -> GenericIterator<T, impl Iterator<Item = T> + use<'a, T, S, R, O>, impl ParallelIterator<Item = T> + use<'a, T, S, R, O>, impl ParIter<Item = T> + use<'a, T, S, R, O>>
where T: Clone + Send + Sync + 'a,

Cloned transformation for the generic iterator.

See cloned for details.

Auto Trait Implementations§

§

impl<T, S, R, O> Freeze for GenericIterator<T, S, R, O>
where S: Freeze, R: Freeze, O: Freeze,

§

impl<T, S, R, O> RefUnwindSafe for GenericIterator<T, S, R, O>

§

impl<T, S, R, O> Send for GenericIterator<T, S, R, O>
where S: Send,

§

impl<T, S, R, O> Sync for GenericIterator<T, S, R, O>
where S: Sync, R: Sync,

§

impl<T, S, R, O> Unpin for GenericIterator<T, S, R, O>
where S: Unpin, R: Unpin, O: Unpin,

§

impl<T, S, R, O> UnwindSafe for GenericIterator<T, S, R, O>
where S: UnwindSafe, R: UnwindSafe, O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SoM<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

fn get_mut(&mut self) -> &mut T

Returns a mutable reference to self.
Source§

impl<T> SoR<T> for T

Source§

fn get_ref(&self) -> &T

Returns a reference to self.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Erased for T