docchi_core/imp/structs/
linked_map_iter_mut.rs1use crate::imp::structs::linked_map_unsafe_iter::LinkedMapUnsafeIter;
2use std::marker::PhantomData;
3use crate::imp::structs::linked_m::{LinkedMap, MutNode};
4
5pub struct LinkedMapIterMut<'a, V>{
6 iter : LinkedMapUnsafeIter<V>,
7 phantom : PhantomData<&'a LinkedMap<V>>,
8}
9impl<'a, V> LinkedMapIterMut<'a, V>{
10 pub(crate) fn new(map : &'a mut LinkedMap<V>, node : *mut MutNode<V>) -> LinkedMapIterMut<'a, V>{
11 LinkedMapIterMut{ iter : LinkedMapUnsafeIter::new(map, node), phantom : PhantomData::default() }
12 }
13
14 pub fn next(&mut self) -> Option<(&'a u64, &'a mut V)> {
16 self.iter.next_mut()
17 }
18
19 pub fn is_available(&self) -> bool {
33 self.iter.is_available()
34 }
35 pub fn is_first(&self) -> bool {
36 self.iter.is_first()
37 }
38 pub fn is_last(&self) -> bool {
39 self.iter.is_first()
40 }
41}
42impl<'a,V> Iterator for LinkedMapIterMut<'a, V>{
43 type Item = (&'a u64, &'a mut V);
44
45 fn next(&mut self) -> Option<Self::Item> {
46 self.next()
47 }
48}
49
50impl<'a,V> IntoIterator for &'a mut LinkedMap<V>{
51 type Item = (&'a u64, &'a mut V);
52 type IntoIter = LinkedMapIterMut<'a, V>;
53
54 fn into_iter(self) -> Self::IntoIter {
55 self.iter_mut()
56 }
57}