Struct nested_containment_list::Overlapping[][src]

pub struct Overlapping<'a, R, S, T> where
    R: RangeBounds<T> + 'a,
    S: RangeBounds<T> + 'a,
    T: Ord + 'a, 
{ /* fields omitted */ }

An Iterator over elements in a NestedContainmentList that overlap a query.

This Iterator is typically created from the NestedContainmentList::overlapping() method.

Iterates over all elements within the NestedContainmentList that overlap with the query interval. These elements are iterated in a nested structure, with all elements contained in other elements being accessed through those elements’ sublist() methods.

Example

use nested_containment_list::NestedContainmentList;
use std::iter::FromIterator;

let nclist = NestedContainmentList::from_iter(vec![1..5, 2..3, 2..4, 5..7]);
let query = 3..6;
let mut overlapping = nclist.overlapping(&query);

let first_element = overlapping.next().unwrap();
let second_element = overlapping.next().unwrap();

// The outermost elements are accessed directly.
assert_eq!(first_element.value, &(1..5));
assert_eq!(second_element.value, &(5..7));

// Contained elements are accessed through their containing element's sublist.
let mut inner_sublist = first_element.sublist();
let inner_element = inner_sublist.next().unwrap();
assert_eq!(inner_element.value, &(2..4));

// Note that 2..3 is not found within the nested iterators, since 2..3 does not overlap with 3..6.

Trait Implementations

impl<'a, R: Debug, S: Debug, T: Debug> Debug for Overlapping<'a, R, S, T> where
    R: RangeBounds<T> + 'a,
    S: RangeBounds<T> + 'a,
    T: Ord + 'a, 
[src]

impl<'a, R, S, T> DoubleEndedIterator for Overlapping<'a, R, S, T> where
    R: RangeBounds<T>,
    S: RangeBounds<T>,
    T: Ord
[src]

impl<'a, R, S, T> FusedIterator for Overlapping<'a, R, S, T> where
    R: RangeBounds<T>,
    S: RangeBounds<T>,
    T: Ord
[src]

impl<'a, R, S, T> Iterator for Overlapping<'a, R, S, T> where
    R: RangeBounds<T>,
    S: RangeBounds<T>,
    T: Ord
[src]

type Item = OverlappingElement<'a, R, S, T>

The type of the elements being iterated over.

fn next(&mut self) -> Option<Self::Item>[src]

Returns the next outer-most element.

Note that any values contained within a returned element must be accessed through the element’s sublist() method.

Example

use nested_containment_list::NestedContainmentList;
use std::iter::FromIterator;

let nclist = NestedContainmentList::from_iter(vec![1..5]);
let query = 2..3;
let mut overlapping = nclist.overlapping(&query);

assert_eq!(overlapping.next().unwrap().value, &(1..5));
assert!(overlapping.next().is_none());

fn last(self) -> Option<Self::Item>[src]

Consumes the iterator, returning the last element.

This method directly uses next_back() to jump straight to the end of the iterator.

Example

use nested_containment_list::NestedContainmentList;
use std::iter::FromIterator;

let nclist = NestedContainmentList::from_iter(vec![1..2, 3..4, 5..6]);

let mut overlapping = nclist.overlapping(&(1..4));
assert_eq!(overlapping.last().unwrap().value, &(3..4));

fn size_hint(&self) -> (usize, Option<usize>)[src]

Returns the bounds on the remaining length of the iterator.

The lower bound will always be 1 unless the iterator has been exhausted, in which case it will be 0. The upper bound will always be provided and will be the total count of remaining elements to be iterated over, including those which are nested and those which may not actually overlap with the query.

Example

use nested_containment_list::NestedContainmentList;
use std::iter::FromIterator;

let nclist = NestedContainmentList::from_iter(vec![1..5, 2..5, 6..7]);
let query = 2..4;
let overlapping = nclist.overlapping(&query);

assert_eq!(overlapping.size_hint(), (1, Some(3)));

Auto Trait Implementations

impl<'a, R, S, T> Send for Overlapping<'a, R, S, T> where
    R: Sync,
    S: Sync,
    T: Sync

impl<'a, R, S, T> Sync for Overlapping<'a, R, S, T> where
    R: Sync,
    S: Sync,
    T: Sync

impl<'a, R, S, T> Unpin for Overlapping<'a, R, S, T>

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> 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, 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.