orx_tree/traversal/depth_first/
iter_mut.rs1use super::dfs_enumeration::DepthFirstEnumeration;
2use super::iter_ptr::DfsIterPtr;
3use super::stack::Item;
4use crate::TreeVariant;
5use crate::aliases::Col;
6use crate::memory::MemoryPolicy;
7use crate::pinned_storage::PinnedStorage;
8use crate::traversal::node_item_mut::NodeItemMut;
9use alloc::vec::Vec;
10use core::marker::PhantomData;
11use orx_self_or::SoM;
12
13pub struct DfsIterMut<'a, V, M, P, E, S, D>
14where
15 V: TreeVariant,
16 M: MemoryPolicy,
17 P: PinnedStorage,
18 E: DepthFirstEnumeration,
19 S: SoM<Vec<Item<V, E>>>,
20 D: NodeItemMut<'a, V, M, P>,
21{
22 col: &'a Col<V, M, P>,
23 iter: DfsIterPtr<V, E, S>,
24 phantom: PhantomData<D>,
25}
26
27impl<'a, V, M, P, E, S, D> DfsIterMut<'a, V, M, P, E, S, D>
28where
29 V: TreeVariant,
30 M: MemoryPolicy,
31 P: PinnedStorage,
32 E: DepthFirstEnumeration,
33 S: SoM<Vec<Item<V, E>>>,
34 D: NodeItemMut<'a, V, M, P>,
35{
36 pub(crate) unsafe fn from((col, iter): (&'a Col<V, M, P>, DfsIterPtr<V, E, S>)) -> Self {
48 Self {
49 col,
50 iter,
51 phantom: PhantomData,
52 }
53 }
54}
55
56impl<'a, V, M, P, E, S, D> Iterator for DfsIterMut<'a, V, M, P, E, S, D>
57where
58 V: TreeVariant,
59 M: MemoryPolicy,
60 P: PinnedStorage,
61 E: DepthFirstEnumeration,
62 S: SoM<Vec<Item<V, E>>>,
63 D: NodeItemMut<'a, V, M, P>,
64{
65 type Item = E::Item<D>;
66
67 fn next(&mut self) -> Option<Self::Item> {
68 self.iter
69 .next()
70 .map(move |element: Item<V, E>| E::from_element_ptr_mut(self.col, element))
71 }
72}