[][src]Struct math::iter::common_refinement_zip::CommonRefinementZipped

pub struct CommonRefinementZipped<B, I, X, P, V> where
    B: Copy + Num + Ord,
    I: Iterator<Item = X> + Sized,
    P: Clone + Interval<B> + for<'b> Intersect<&'b P, Option<P>>, 
{ /* fields omitted */ }

Iterator Algorithm Description

Given a list of iterators, a list of the current minimum interval for each iterator will be maintained together with their associated values. Then, at each pass the smallest minimum common refinement of the current intervals is subtracted from each interval. A list of values will be returned along with the common refinement. Each value will be the value associated with the iterated interval if the common refinement has a non-empty intersection with the corresponding interval, and None otherwise.

If an interval becomes empty after the subtraction, the corresponding iterator will be called to replace the interval with the next interval, together with the associated values.

Fields

  • iters: the list of zipped iterators.
  • intervals: the intervals assocaited with each iterator for the current pass.
  • values: the values associated with each iterator for the current pass.
  • extractor: a function that extracts a tuple of (interval, value) from each of the items yielded from the iterators.

Implementations

impl<B, I, X, P, V> CommonRefinementZipped<B, I, X, P, V> where
    B: Copy + Num + Ord,
    I: Iterator<Item = X> + Sized,
    P: Clone + Interval<B> + for<'b> Intersect<&'b P, Option<P>>, 
[src]

pub fn common_refinement_flat_zip(
    self,
    other: I
) -> CommonRefinementZipped<B, I, X, P, V>

Important traits for CommonRefinementZipped<B, I, X, P, V>

impl<B, I, X, P, V> Iterator for CommonRefinementZipped<B, I, X, P, V> where
    B: Copy + Num + Ord,
    I: Iterator<Item = X> + Sized,
    P: Clone + Interval<B> + for<'b> Intersect<&'b P, Option<P>>,
    V: Clone
type Item = (P, Vec<Option<V>>);
where
    I: Iterator<Item = X> + Sized
[src]

use analytic::{
    interval::{traits::Interval, IntInterval},
    iter::CommonRefinementZip,
};
use std::collections::BTreeMap;

let m1: BTreeMap<IntInterval<usize>, i32> =
    vec![(IntInterval::new(0, 10), 5), (IntInterval::new(16, 17), 21)]
        .into_iter()
        .collect();

let m2: BTreeMap<IntInterval<usize>, i32> =
    vec![(IntInterval::new(2, 3), 8), (IntInterval::new(12, 20), 9)]
        .into_iter()
        .collect();

let m3: BTreeMap<IntInterval<usize>, i32> = vec![
    (IntInterval::new(2, 4), 7),
    (IntInterval::new(9, 10), -1),
    (IntInterval::new(15, 20), 0),
]
.into_iter()
.collect();

let mut iter = m1
    .iter()
    .common_refinement_zip(m2.iter())
    .common_refinement_flat_zip(m3.iter());

assert_eq!(
    Some((IntInterval::new(0, 1), vec![Some(5), None, None])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(2, 3), vec![Some(5), Some(8), Some(7)])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(4, 4), vec![Some(5), None, Some(7)])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(5, 8), vec![Some(5), None, None])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(9, 10), vec![Some(5), None, Some(-1)])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(12, 14), vec![None, Some(9), None])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(15, 15), vec![None, Some(9), Some(0)])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(16, 17), vec![Some(21), Some(9), Some(0)])),
    iter.next()
);
assert_eq!(
    Some((IntInterval::new(18, 20), vec![None, Some(9), Some(0)])),
    iter.next()
);
assert_eq!(None, iter.next());

Trait Implementations

impl<B, I, X, P, V> Iterator for CommonRefinementZipped<B, I, X, P, V> where
    B: Copy + Num + Ord,
    I: Iterator<Item = X> + Sized,
    P: Clone + Interval<B> + for<'b> Intersect<&'b P, Option<P>>,
    V: Clone
[src]

type Item = (P, Vec<Option<V>>)

The type of the elements being iterated over.

Auto Trait Implementations

impl<B, I, X, P, V> !RefUnwindSafe for CommonRefinementZipped<B, I, X, P, V>

impl<B, I, X, P, V> !Send for CommonRefinementZipped<B, I, X, P, V>

impl<B, I, X, P, V> !Sync for CommonRefinementZipped<B, I, X, P, V>

impl<B, I, X, P, V> Unpin for CommonRefinementZipped<B, I, X, P, V> where
    B: Unpin,
    I: Unpin,
    P: Unpin,
    V: Unpin

impl<B, I, X, P, V> !UnwindSafe for CommonRefinementZipped<B, I, X, P, V>

Blanket Implementations

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

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

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

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

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

impl<I, V> IntoBinnedIntervalIter<V> for I where
    I: Iterator,
    V: Copy + Num + FromPrimitive + PartialOrd<V>, 
[src]

impl<I> IntoFlatZipIter<I> for I where
    I: Iterator
[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<I> IteratorRandom for I where
    I: Iterator
[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<V, T> VZip<V> for T where
    V: MultiLane<T>,