[][src]Struct hopscotch::Iter

pub struct Iter<'a, 'b, K, V, Tags> where
    K: Ord + Clone + 'b,
    Tags: Iterator<Item = &'b K> + Clone
{ /* fields omitted */ }

An iterator over immutable references to items in a queue.

Methods

impl<'a, 'b, K, V, T> Iter<'a, 'b, K, V, T> where
    K: Ord + Clone + 'b,
    T: Iterator<Item = &'b K> + Clone
[src]

pub fn after(self, earliest: u64) -> Iter<'a, 'b, K, V, T>[src]

Restrict this iterator to indices greater than or equal to earliest.

Examples

use hopscotch::Queue;

let queue: Queue<usize, usize> = (0..=3).zip(0..=3).collect();
let vec: Vec<_> = queue.iter().after(2).map(|i| *i.value()).collect();
assert_eq!(&vec, &[2, 3]);

pub fn until(self, latest: u64) -> Iter<'a, 'b, K, V, T>[src]

Restrict this iterator to indices less than or equal to latest.

Examples

use hopscotch::Queue;

let queue: Queue<usize, usize> = (0..=3).zip(0..=3).collect();
let vec: Vec<_> = queue.iter().until(1).map(|i| *i.value()).collect();
assert_eq!(&vec, &[0, 1]);

pub fn matching_only<Tags>(
    self,
    tags: Tags
) -> Iter<'a, 'b, K, V, Tags::IntoIter> where
    Tags: IntoIterator<Item = &'b K>,
    Tags::IntoIter: Clone
[src]

Restrict this iterator to tags in the given list of tags.

This has the same efficiency characteristics as the before and after methods: each item is produced in constant time relative to the distance between matching tags.

If matching_only is called twice, the set of tags given in the second call completely overrides those given in the first.

Examples

use hopscotch::Queue;

let queue: Queue<usize, usize> =
    [0, 1, 0, 1].iter().copied().zip(0..=3).collect();
let vec: Vec<_> =
    queue.iter().matching_only(&[1]).map(|i| *i.value()).collect();
assert_eq!(&vec, &[1, 3]);

Trait Implementations

impl<'a, 'b, K: Clone, V: Clone, Tags: Clone> Clone for Iter<'a, 'b, K, V, Tags> where
    K: Ord + Clone + 'b,
    Tags: Iterator<Item = &'b K> + Clone
[src]

impl<'a, 'b, K, V, Tags> DoubleEndedIterator for Iter<'a, 'b, K, V, Tags> where
    K: Ord + Clone + 'b,
    Tags: Iterator<Item = &'b K> + Clone
[src]

impl<'a, 'b, K, V, Tags> Iterator for Iter<'a, 'b, K, V, Tags> where
    K: Ord + Clone + 'b,
    Tags: Iterator<Item = &'b K> + Clone
[src]

type Item = Item<'a, K, V>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a, 'b, K, V, Tags> !RefUnwindSafe for Iter<'a, 'b, K, V, Tags>

impl<'a, 'b, K, V, Tags> !Send for Iter<'a, 'b, K, V, Tags>

impl<'a, 'b, K, V, Tags> !Sync for Iter<'a, 'b, K, V, Tags>

impl<'a, 'b, K, V, Tags> Unpin for Iter<'a, 'b, K, V, Tags> where
    Tags: Unpin

impl<'a, 'b, K, V, Tags> !UnwindSafe for Iter<'a, 'b, K, V, Tags>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.