use std::cmp::{Ord, Eq};
use std::hash::Hash;
use std::iter::*;
use ::pqueue::PriorityQueue;
pub struct Iter<'a, I:'a, P:'a> {
pub(crate) iter: ::ordermap::Iter<'a, I, Option<P>>
}
impl<'a, I: 'a, P: 'a> Iterator for Iter<'a, I, P>
where I: Hash + Eq,
P: Ord {
type Item = (&'a I, &'a P);
fn next(&mut self) -> Option<(&'a I, &'a P)> {
self.iter.next().map(|(i, op)| (i, op.as_ref().unwrap()))
}
}
pub struct IntoIter<I,P>
where I:Hash + Eq,
P:Ord{
pub(crate) iter: ::ordermap::IntoIter<I, Option<P>>
}
impl<I, P> Iterator for IntoIter<I, P>
where I:Hash + Eq,
P:Ord {
type Item = (I, P);
fn next(&mut self) -> Option<(I, P)> {
self.iter.next().map(|(i, op)| (i, op.unwrap()))
}
}
pub struct IntoSortedIter<I, P>
where I:Hash + Eq,
P:Ord {
pub(crate) pq: PriorityQueue<I, P>
}
impl<I, P> Iterator for IntoSortedIter<I, P>
where I: Hash + Eq,
P:Ord {
type Item = (I, P);
fn next(&mut self) -> Option<(I, P)> {
self.pq.pop()
}
}