1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use crate::imp::structs::linked_m::{LinkedMap, MutNode};
use crate::imp::structs::linked_map_unsafe_iter::LinkedMapUnsafeIter;
use std::marker::PhantomData;
pub struct LinkedMapIter<'a, V>{
iter : LinkedMapUnsafeIter<V>,
phantom : PhantomData<&'a LinkedMap<V>>,
}
impl<'a, V> LinkedMapIter<'a, V>{
pub(crate) fn new(map : &'a LinkedMap<V>, node : *const MutNode<V>) -> LinkedMapIter<'a, V>{
LinkedMapIter{ iter : LinkedMapUnsafeIter::new(map, node), phantom : PhantomData::default() }
}
pub fn next(&mut self) -> Option<(&'a u64, &'a V)> {
self.iter.next_const()
}
pub fn prev(&mut self) -> Option<(&'a u64, &'a V)> {
self.iter.prev_const()
}
pub fn current(&mut self) -> Option<(&'a u64, &'a V)> {
self.iter.current_const()
}
pub fn is_available(&self) -> bool {
self.iter.is_available()
}
pub fn is_first(&self) -> bool {
self.iter.is_first()
}
pub fn is_last(&self) -> bool {
self.iter.is_first()
}
}
impl<'a,V> Iterator for LinkedMapIter<'a, V>{
type Item = (&'a u64, &'a V);
fn next(&mut self) -> Option<Self::Item> {
self.next()
}
}
impl<'a,V> IntoIterator for &'a LinkedMap<V>{
type Item = (&'a u64, &'a V);
type IntoIter = LinkedMapIter<'a, V>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}