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