Struct ConIterOfRange

Source
pub struct ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,
{ /* private fields */ }
Expand description

A concurrent iterator over a slice yielding references to the elements.

Implementations§

Source§

impl<Idx> ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Source

pub fn new(range: Range<Idx>) -> Self

Creates a concurrent iterator for the given range.

Trait Implementations§

Source§

impl<Idx> Clone for ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Idx> ConcurrentIter for ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Source§

type BufferedIter = <ConIterOfRange<Idx> as ConcurrentIterX>::BufferedIterX

Type of the buffered iterator returned by the chunk_iter method when elements are fetched in chunks by each thread.
Source§

fn next_id_and_value(&self) -> Option<Next<Self::Item>>

Advances the iterator and returns the next value together with its enumeration index. Read more
Source§

fn next_chunk( &self, chunk_size: usize, ) -> Option<NextChunk<Self::Item, impl ExactSizeIterator<Item = Self::Item>>>

Advances the iterator chunk_size times and returns an iterator of at most chunk_size consecutive next values. Further, the beginning enumeration index of the yielded values is returned. Read more
Source§

fn into_con_iter_x(self) -> impl ConcurrentIterX<Item = Self::Item>
where Self: Sized,

Converts the ConcurrentIter into a ConcurrentIterX. Read more
Source§

fn ids_and_values(&self) -> ConIterIdsAndValues<'_, Self>
where Self: Sized,

Returns an Iterator over the ids and values of elements of the concurrent iterator. Read more
Source§

fn for_each<Fun: FnMut(Self::Item)>(&self, chunk_size: usize, fun: Fun)
where Self: Sized,

Applies the function fun to each element of the iterator concurrently. Read more
Source§

fn enumerate_for_each<Fun: FnMut(usize, Self::Item)>( &self, chunk_size: usize, fun: Fun, )
where Self: Sized,

Applies the function fun to each index and corresponding element of the iterator concurrently. Read more
Source§

fn buffered_iter( &self, chunk_size: usize, ) -> BufferedIter<'_, Self::Item, Self::BufferedIter>

Creates an iterator which pulls elements from this iterator as chunks of the given chunk_size. Read more
Source§

impl<Idx> ConcurrentIterX for ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Source§

fn into_seq_iter(self) -> Self::SeqIter

Converts the concurrent iterator back to the original wrapped type which is the source of the elements to be iterated. Already progressed elements are skipped.

§Examples
use orx_concurrent_iter::*;

let range = 0..1024;
let con_iter = range.con_iter();

std::thread::scope(|s| {
    s.spawn(|| {
        for _ in 0..42 {
            _ = con_iter.next();
        }

        let mut buffered = con_iter.buffered_iter(32);
        let _chunk = buffered.next().unwrap();
    });
});

let num_used = 42 + 32;

// converts the remaining elements into a sequential iterator
let seq_iter = con_iter.into_seq_iter();

assert_eq!(seq_iter.len(), 1024 - num_used);
for (i, x) in seq_iter.enumerate() {
    assert_eq!(x, num_used + i);
}
Source§

type Item = Idx

Type of the items that the iterator yields.
Source§

type SeqIter = Range<Idx>

Inner type which is the source of the data to be iterated, which in addition is a regular sequential Iterator.
Source§

type BufferedIterX = BufferedRange

Type of the buffered iterator returned by the buffered_iter_x method when elements are fetched in chunks by each thread.
Source§

fn next_chunk_x( &self, chunk_size: usize, ) -> Option<impl ExactSizeIterator<Item = Self::Item>>

Advances the iterator chunk_size times and returns an iterator of at most chunk_size consecutive next values. Read more
Source§

fn next(&self) -> Option<Self::Item>

Advances the iterator and returns the next value. Read more
Source§

fn try_get_len(&self) -> Option<usize>

Returns Some of the remaining length of the iterator if it is known; returns None otherwise.
Source§

fn try_get_initial_len(&self) -> Option<usize>

Returns Some of the initial length of the iterator when it was constructed if it is known; returns None otherwise. Read more
Source§

fn skip_to_end(&self)

Skips all remaining elements of the iterator and assumes that the end of the iterator is reached. Read more
Source§

fn values(&self) -> ConIterValuesX<'_, Self>
where Self: Sized,

Returns an Iterator over the values of elements of the concurrent iterator. Read more
Source§

fn for_each_x<Fun: FnMut(Self::Item)>(&self, chunk_size: usize, fun: Fun)
where Self: Sized,

Applies the function fun to each element of the iterator concurrently. Read more
Source§

fn fold<B, Fold>(&self, chunk_size: usize, neutral: B, fold: Fold) -> B
where Fold: FnMut(B, Self::Item) -> B, Self: Sized,

Folds the elements of the iterator pulled concurrently using fold function. Read more
Source§

fn has_more(&self) -> HasMore

Returns whether or not the concurrent iterator has more elements to yield. Read more
Source§

fn buffered_iter_x( &self, chunk_size: usize, ) -> BufferedIter<'_, Self::Item, Self::BufferedIterX>

Creates an iterator which pulls elements from this iterator as chunks of the given chunk_size. Read more
Source§

impl<Idx> Debug for ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Idx> From<Range<Idx>> for ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Source§

fn from(range: Range<Idx>) -> Self

Creates a concurrent iterator for the given range.

Source§

impl<Idx> Send for ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Source§

impl<Idx> Sync for ConIterOfRange<Idx>
where Idx: Send + Sync + Clone + Copy + From<usize> + Into<usize> + Add<Idx, Output = Idx> + Sub<Idx, Output = Idx> + Ord, Range<Idx>: Iterator<Item = Idx>,

Auto Trait Implementations§

§

impl<Idx> !Freeze for ConIterOfRange<Idx>

§

impl<Idx> RefUnwindSafe for ConIterOfRange<Idx>
where Idx: RefUnwindSafe,

§

impl<Idx> Unpin for ConIterOfRange<Idx>
where Idx: Unpin,

§

impl<Idx> UnwindSafe for ConIterOfRange<Idx>
where Idx: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.