1use super::breadth_first::BreadthFirstEnumeration;
2use super::depth_first::DepthFirstEnumeration;
3use super::node_item::NodeItem;
4use super::post_order::PostOrderEnumeration;
5use crate::memory::{Auto, MemoryPolicy};
6use crate::pinned_storage::{PinnedStorage, SplitRecursive};
7use crate::traversal::enumeration::Enumeration;
8use crate::traversal::enumerations::{DepthSiblingIdxVal, DepthVal, SiblingIdxVal, Val};
9use crate::{Node, TreeVariant};
10use orx_selfref_col::NodePtr;
11
12pub type OverItem<'a, V, O, M = Auto, P = SplitRecursive> =
13 <<O as Over>::Enumeration as Enumeration>::Item<<O as Over>::NodeItem<'a, V, M, P>>;
14
15pub trait Over: 'static {
20 type Enumeration: Enumeration
23 + PostOrderEnumeration
24 + DepthFirstEnumeration
25 + BreadthFirstEnumeration;
26
27 type NodeItem<'a, V, M, P>: NodeItem<'a, V, M, P>
29 where
30 V: TreeVariant,
31 M: MemoryPolicy,
32 P: PinnedStorage,
33 V: 'a,
34 Self: 'a;
35
36 type IntoOverData: Over;
38
39 type IntoOverNode: Over;
41
42 type IntoWithDepth: Over;
49
50 type IntoWithSiblingIdx: Over;
57}
58
59pub struct OverData;
66
67impl Over for OverData {
68 type Enumeration = Val;
69
70 type NodeItem<'a, V, M, P>
71 = &'a V::Item
72 where
73 M: MemoryPolicy,
74 P: PinnedStorage,
75 V: TreeVariant + 'a,
76 Self: 'a;
77
78 type IntoOverData = Self;
79 type IntoOverNode = OverNode;
80 type IntoWithDepth = OverDepthData;
81 type IntoWithSiblingIdx = OverSiblingIdxData;
82}
83
84pub struct OverNode;
88
89impl Over for OverNode {
90 type Enumeration = Val;
91
92 type NodeItem<'a, V, M, P>
93 = Node<'a, V, M, P>
94 where
95 M: MemoryPolicy,
96 P: PinnedStorage,
97 V: TreeVariant + 'a,
98 Self: 'a;
99
100 type IntoOverData = OverData;
101 type IntoOverNode = Self;
102 type IntoWithDepth = OverDepthNode;
103 type IntoWithSiblingIdx = OverSiblingIdxNode;
104}
105
106pub(crate) struct OverPtr;
107
108impl Over for OverPtr {
109 type Enumeration = Val;
110
111 type NodeItem<'a, V, M, P>
112 = NodePtr<V>
113 where
114 M: MemoryPolicy,
115 P: PinnedStorage,
116 V: TreeVariant + 'a,
117 Self: 'a;
118
119 type IntoOverData = OverData;
120 type IntoOverNode = OverNode;
121 type IntoWithDepth = OverDepthPtr;
122 type IntoWithSiblingIdx = OverSiblingIdxPtr;
123}
124
125pub struct OverDepthData;
136
137impl Over for OverDepthData {
138 type Enumeration = DepthVal;
139
140 type NodeItem<'a, V, M, P>
141 = &'a V::Item
142 where
143 M: MemoryPolicy,
144 P: PinnedStorage,
145 V: TreeVariant + 'a,
146 Self: 'a;
147
148 type IntoOverData = Self;
149 type IntoOverNode = OverDepthNode;
150 type IntoWithDepth = OverDepthData;
151 type IntoWithSiblingIdx = OverDepthSiblingIdxData;
152}
153
154pub struct OverDepthNode;
162
163impl Over for OverDepthNode {
164 type Enumeration = DepthVal;
165
166 type NodeItem<'a, V, M, P>
167 = Node<'a, V, M, P>
168 where
169 M: MemoryPolicy,
170 P: PinnedStorage,
171 V: TreeVariant + 'a,
172 Self: 'a;
173
174 type IntoOverData = OverDepthData;
175 type IntoOverNode = Self;
176 type IntoWithDepth = OverDepthNode;
177 type IntoWithSiblingIdx = OverDepthSiblingIdxNode;
178}
179
180pub(crate) struct OverDepthPtr;
181
182impl Over for OverDepthPtr {
183 type Enumeration = DepthVal;
184
185 type NodeItem<'a, V, M, P>
186 = NodePtr<V>
187 where
188 M: MemoryPolicy,
189 P: PinnedStorage,
190 V: TreeVariant + 'a,
191 Self: 'a;
192
193 type IntoOverData = OverData;
194 type IntoOverNode = OverNode;
195 type IntoWithDepth = OverDepthPtr;
196 type IntoWithSiblingIdx = OverDepthSiblingIdxPtr;
197}
198
199pub struct OverSiblingIdxData;
212
213impl Over for OverSiblingIdxData {
214 type Enumeration = SiblingIdxVal;
215
216 type NodeItem<'a, V, M, P>
217 = &'a V::Item
218 where
219 M: MemoryPolicy,
220 P: PinnedStorage,
221 V: TreeVariant + 'a,
222 Self: 'a;
223
224 type IntoOverData = Self;
225 type IntoOverNode = OverSiblingIdxNode;
226 type IntoWithDepth = OverDepthSiblingIdxData;
227 type IntoWithSiblingIdx = OverSiblingIdxData;
228}
229
230pub struct OverSiblingIdxNode;
240
241impl Over for OverSiblingIdxNode {
242 type Enumeration = SiblingIdxVal;
243
244 type NodeItem<'a, V, M, P>
245 = Node<'a, V, M, P>
246 where
247 M: MemoryPolicy,
248 P: PinnedStorage,
249 V: TreeVariant + 'a,
250 Self: 'a;
251
252 type IntoOverData = OverSiblingIdxData;
253 type IntoOverNode = Self;
254 type IntoWithDepth = OverDepthSiblingIdxNode;
255 type IntoWithSiblingIdx = OverSiblingIdxNode;
256}
257
258pub(crate) struct OverSiblingIdxPtr;
259
260impl Over for OverSiblingIdxPtr {
261 type Enumeration = Val;
262
263 type NodeItem<'a, V, M, P>
264 = NodePtr<V>
265 where
266 M: MemoryPolicy,
267 P: PinnedStorage,
268 V: TreeVariant + 'a,
269 Self: 'a;
270
271 type IntoOverData = OverData;
272 type IntoOverNode = OverNode;
273 type IntoWithDepth = OverDepthSiblingIdxPtr;
274 type IntoWithSiblingIdx = OverSiblingIdxPtr;
275}
276
277pub struct OverDepthSiblingIdxData;
294
295impl Over for OverDepthSiblingIdxData {
296 type Enumeration = DepthSiblingIdxVal;
297
298 type NodeItem<'a, V, M, P>
299 = &'a V::Item
300 where
301 M: MemoryPolicy,
302 P: PinnedStorage,
303 V: TreeVariant + 'a,
304 Self: 'a;
305
306 type IntoOverData = Self;
307 type IntoOverNode = OverDepthSiblingIdxNode;
308 type IntoWithDepth = Self;
309 type IntoWithSiblingIdx = Self;
310}
311
312pub struct OverDepthSiblingIdxNode;
326
327impl Over for OverDepthSiblingIdxNode {
328 type Enumeration = DepthSiblingIdxVal;
329
330 type NodeItem<'a, V, M, P>
331 = Node<'a, V, M, P>
332 where
333 M: MemoryPolicy,
334 P: PinnedStorage,
335 V: TreeVariant + 'a,
336 Self: 'a;
337
338 type IntoOverData = OverDepthSiblingIdxData;
339 type IntoOverNode = Self;
340 type IntoWithDepth = Self;
341 type IntoWithSiblingIdx = Self;
342}
343pub(crate) struct OverDepthSiblingIdxPtr;
344
345impl Over for OverDepthSiblingIdxPtr {
346 type Enumeration = Val;
347
348 type NodeItem<'a, V, M, P>
349 = NodePtr<V>
350 where
351 M: MemoryPolicy,
352 P: PinnedStorage,
353 V: TreeVariant + 'a,
354 Self: 'a;
355
356 type IntoOverData = OverData;
357 type IntoOverNode = OverNode;
358 type IntoWithDepth = Self;
359 type IntoWithSiblingIdx = Self;
360}