flow::binary
This commit is contained in:
parent
8b4c5d0b43
commit
08d0404ee5
@ -1 +1 @@
|
|||||||
Subproject commit 343baf150fe86ad6cd3594828068d42e7bc25b18
|
Subproject commit bb44e06dea5b3a00585066063be00c4b3a976f70
|
@ -1,3 +1,4 @@
|
|||||||
//! Data structures and algorithms, independent of [`crate::core`] concepts.
|
//! Data structures and algorithms, independent of [`crate::core`] concepts.
|
||||||
|
|
||||||
|
pub mod binary;
|
||||||
pub mod traversible;
|
pub mod traversible;
|
||||||
|
30
src/flow/binary.rs
Normal file
30
src/flow/binary.rs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
use crate::func::*;
|
||||||
|
|
||||||
|
pub type NodeRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Node>;
|
||||||
|
pub type ReferenceRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Reference>;
|
||||||
|
pub type TreeRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Tree>;
|
||||||
|
pub type KeyRc<'a, BT> = Rc<<BT as BinaryTrees<'a>>::Key>;
|
||||||
|
|
||||||
|
pub type Split<'a, BT> = (TreeRc<'a, BT>, TreeRc<'a, BT>, KeyRc<'a, BT>);
|
||||||
|
|
||||||
|
pub type Wrapped<'a, BT, A> = <<BT as BinaryTrees<'a>>::T as WeakFunctor>::F<'a, A>;
|
||||||
|
|
||||||
|
pub trait BinaryTrees<'a>: 'a {
|
||||||
|
type Node: 'a;
|
||||||
|
type Reference: 'a;
|
||||||
|
type Tree: 'a;
|
||||||
|
type Key: 'a;
|
||||||
|
|
||||||
|
type T: 'a + Monad;
|
||||||
|
|
||||||
|
fn split(node: Self::Node) -> Wrapped<'a, Self, Split<'a, Self>>;
|
||||||
|
fn to_tree(node: Self::Node) -> TreeRc<'a, Self>;
|
||||||
|
fn to_tree_construct(&self, node: Self::Node) -> TreeRc<'a, Self> {
|
||||||
|
Self::to_tree(node)
|
||||||
|
}
|
||||||
|
fn resolve(reference: Self::Reference) -> Wrapped<'a, Self, NodeRc<'a, Self>>;
|
||||||
|
fn equal(rhs: Self::Reference, lhs: Self::Reference) -> bool;
|
||||||
|
fn refer(tree: Self::Tree) -> Option<ReferenceRc<'a, Self>>;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user