[][src]Struct merging_iterator::MergeIter

pub struct MergeIter<L, R, T> where
    L: Iterator<Item = T>,
    R: Iterator<Item = T>, 
{ /* fields omitted */ }

A sorted iterator over two independent sorted iterators.

Methods

impl<L, R, T> MergeIter<L, R, T> where
    L: Iterator<Item = T>,
    R: Iterator<Item = T>,
    T: Ord
[src]

pub fn new<IL, IR>(left: IL, right: IR) -> Self where
    IL: IntoIterator<IntoIter = L, Item = T>,
    IR: IntoIterator<IntoIter = R, Item = T>, 
[src]

Creates a new MergeIter that returns elements from both supplied iterators in order, given they are sorted.

Examples

use merging_iterator::MergeIter;
let a = vec![0, 2, 4, 6, 8];
let b = vec![1, 3, 5, 7, 9];
let merger = MergeIter::new(a, b);
assert_eq!(
    vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
    merger.collect::<Vec<_>>()
);

impl<L, R, T> MergeIter<L, R, T> where
    L: Iterator<Item = T>,
    R: Iterator<Item = T>, 
[src]

pub fn with_custom_ordering<IL, IR>(
    left: IL,
    right: IR,
    cmp: fn(_: &T, _: &T) -> bool
) -> Self where
    IL: IntoIterator<IntoIter = L, Item = T>,
    IR: IntoIterator<IntoIter = R, Item = T>, 
[src]

Creates a new MergeIter that uses a custom ordering function.

Examples

use merging_iterator::MergeIter;
let a = vec![8, 6, 4, 2, 0];
let b = vec![9, 7, 5, 3, 1];
let cmp = |a: &u8, b: &u8| b < a;
let merger = MergeIter::with_custom_ordering(a, b, cmp);
assert_eq!(
    vec![9, 8, 7, 6, 5, 4, 3, 2, 1, 0],
    merger.collect::<Vec<_>>()
);

Trait Implementations

impl<L, R, T> From<(L, R)> for MergeIter<L, R, T> where
    L: Iterator<Item = T>,
    R: Iterator<Item = T>,
    T: Ord
[src]

impl<L, R, T> Iterator for MergeIter<L, R, T> where
    L: Iterator<Item = T>,
    R: Iterator<Item = T>,
    T: Ord
[src]

type Item = T

The type of the elements being iterated over.

Auto Trait Implementations

impl<L, R, T> Send for MergeIter<L, R, T> where
    L: Send,
    R: Send,
    T: Send

impl<L, R, T> Unpin for MergeIter<L, R, T> where
    L: Unpin,
    R: Unpin,
    T: Unpin

impl<L, R, T> Sync for MergeIter<L, R, T> where
    L: Sync,
    R: Sync,
    T: Sync

impl<L, R, T> RefUnwindSafe for MergeIter<L, R, T> where
    L: RefUnwindSafe,
    R: RefUnwindSafe,
    T: RefUnwindSafe

impl<L, R, T> UnwindSafe for MergeIter<L, R, T> where
    L: UnwindSafe,
    R: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]