use super::breadth_first::BreadthFirstEnumeration;
use super::depth_first::DepthFirstEnumeration;
use super::node_item::NodeItem;
use super::post_order::PostOrderEnumeration;
use crate::memory::{Auto, MemoryPolicy};
use crate::pinned_storage::{PinnedStorage, SplitRecursive};
use crate::traversal::enumeration::Enumeration;
use crate::traversal::enumerations::{DepthSiblingIdxVal, DepthVal, SiblingIdxVal, Val};
use crate::{Node, TreeVariant};
use orx_selfref_col::NodePtr;
pub type OverItem<'a, V, O, M = Auto, P = SplitRecursive> =
<<O as Over>::Enumeration as Enumeration>::Item<<O as Over>::NodeItem<'a, V, M, P>>;
pub trait Over: 'static {
type Enumeration: Enumeration
+ PostOrderEnumeration
+ DepthFirstEnumeration
+ BreadthFirstEnumeration;
type NodeItem<'a, V, M, P>: NodeItem<'a, V, M, P>
where
V: TreeVariant,
M: MemoryPolicy,
P: PinnedStorage,
V: 'a,
Self: 'a;
type IntoOverData: Over;
type IntoOverNode: Over;
type IntoWithDepth: Over;
type IntoWithSiblingIdx: Over;
}
pub struct OverData;
impl Over for OverData {
type Enumeration = Val;
type NodeItem<'a, V, M, P>
= &'a V::Item
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = Self;
type IntoOverNode = OverNode;
type IntoWithDepth = OverDepthData;
type IntoWithSiblingIdx = OverSiblingIdxData;
}
pub struct OverNode;
impl Over for OverNode {
type Enumeration = Val;
type NodeItem<'a, V, M, P>
= Node<'a, V, M, P>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverData;
type IntoOverNode = Self;
type IntoWithDepth = OverDepthNode;
type IntoWithSiblingIdx = OverSiblingIdxNode;
}
pub(crate) struct OverPtr;
impl Over for OverPtr {
type Enumeration = Val;
type NodeItem<'a, V, M, P>
= NodePtr<V>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverData;
type IntoOverNode = OverNode;
type IntoWithDepth = OverDepthPtr;
type IntoWithSiblingIdx = OverSiblingIdxPtr;
}
pub struct OverDepthData;
impl Over for OverDepthData {
type Enumeration = DepthVal;
type NodeItem<'a, V, M, P>
= &'a V::Item
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = Self;
type IntoOverNode = OverDepthNode;
type IntoWithDepth = OverDepthData;
type IntoWithSiblingIdx = OverDepthSiblingIdxData;
}
pub struct OverDepthNode;
impl Over for OverDepthNode {
type Enumeration = DepthVal;
type NodeItem<'a, V, M, P>
= Node<'a, V, M, P>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverDepthData;
type IntoOverNode = Self;
type IntoWithDepth = OverDepthNode;
type IntoWithSiblingIdx = OverDepthSiblingIdxNode;
}
pub(crate) struct OverDepthPtr;
impl Over for OverDepthPtr {
type Enumeration = DepthVal;
type NodeItem<'a, V, M, P>
= NodePtr<V>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverData;
type IntoOverNode = OverNode;
type IntoWithDepth = OverDepthPtr;
type IntoWithSiblingIdx = OverDepthSiblingIdxPtr;
}
pub struct OverSiblingIdxData;
impl Over for OverSiblingIdxData {
type Enumeration = SiblingIdxVal;
type NodeItem<'a, V, M, P>
= &'a V::Item
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = Self;
type IntoOverNode = OverSiblingIdxNode;
type IntoWithDepth = OverDepthSiblingIdxData;
type IntoWithSiblingIdx = OverSiblingIdxData;
}
pub struct OverSiblingIdxNode;
impl Over for OverSiblingIdxNode {
type Enumeration = SiblingIdxVal;
type NodeItem<'a, V, M, P>
= Node<'a, V, M, P>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverSiblingIdxData;
type IntoOverNode = Self;
type IntoWithDepth = OverDepthSiblingIdxNode;
type IntoWithSiblingIdx = OverSiblingIdxNode;
}
pub(crate) struct OverSiblingIdxPtr;
impl Over for OverSiblingIdxPtr {
type Enumeration = Val;
type NodeItem<'a, V, M, P>
= NodePtr<V>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverData;
type IntoOverNode = OverNode;
type IntoWithDepth = OverDepthSiblingIdxPtr;
type IntoWithSiblingIdx = OverSiblingIdxPtr;
}
pub struct OverDepthSiblingIdxData;
impl Over for OverDepthSiblingIdxData {
type Enumeration = DepthSiblingIdxVal;
type NodeItem<'a, V, M, P>
= &'a V::Item
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = Self;
type IntoOverNode = OverDepthSiblingIdxNode;
type IntoWithDepth = Self;
type IntoWithSiblingIdx = Self;
}
pub struct OverDepthSiblingIdxNode;
impl Over for OverDepthSiblingIdxNode {
type Enumeration = DepthSiblingIdxVal;
type NodeItem<'a, V, M, P>
= Node<'a, V, M, P>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverDepthSiblingIdxData;
type IntoOverNode = Self;
type IntoWithDepth = Self;
type IntoWithSiblingIdx = Self;
}
pub(crate) struct OverDepthSiblingIdxPtr;
impl Over for OverDepthSiblingIdxPtr {
type Enumeration = Val;
type NodeItem<'a, V, M, P>
= NodePtr<V>
where
M: MemoryPolicy,
P: PinnedStorage,
V: TreeVariant + 'a,
Self: 'a;
type IntoOverData = OverData;
type IntoOverNode = OverNode;
type IntoWithDepth = Self;
type IntoWithSiblingIdx = Self;
}