From f5791c930d7ec3376336ad39f9c46ab84aeea2c6 Mon Sep 17 00:00:00 2001 From: timofey Date: Mon, 29 May 2023 16:34:57 +0000 Subject: [PATCH] rework `BinaryTrees` --- src/flow/binary.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/flow/binary.rs b/src/flow/binary.rs index c95b5e5..a330f32 100644 --- a/src/flow/binary.rs +++ b/src/flow/binary.rs @@ -12,7 +12,7 @@ pub type KeyRc<'a, BT> = Rc<>::Key>; pub type Split<'a, BT> = (TreeRc<'a, BT>, TreeRc<'a, BT>, KeyRc<'a, BT>); pub type KeySplit<'a, BT> = (TreeRc<'a, BT>, TreeRc<'a, BT>); -pub type Wrapped<'a, BT, A> = Wrap<'a, A, >::T>; +pub type BTWrap<'a, BT, A> = Wrap<'a, A, >::T>; pub trait BinaryTrees<'a>: 'a { type Node: 'a; @@ -24,11 +24,11 @@ pub trait BinaryTrees<'a>: 'a { type T: Monad<'a>; fn comparator(&self) -> &Self::Comparator; - fn split(&self, node: Self::Node) -> Split<'a, Self>; - fn to_tree(&self, node: Self::Node) -> TreeRc<'a, Self>; - fn resolve(&self, reference: Self::Reference) -> Wrapped<'a, Self, NodeRc<'a, Self>>; - fn equal(&self, rhs: Self::Reference, lhs: Self::Reference) -> bool; - fn refer(&self, tree: Self::Tree) -> Option>; + fn split(&self, node: &Self::Node) -> Split<'a, Self>; + fn tree_of(&self, node: Self::Node) -> TreeRc<'a, Self>; + fn resolve(&self, reference: &Self::Reference) -> BTWrap<'a, Self, NodeRc<'a, Self>>; + fn equal(&self, rhs: &Self::Reference, lhs: &Self::Reference) -> bool; + fn refer(&self, tree: &Self::Tree) -> Option>; } pub trait BinaryTreesMutable<'a>: BinaryTrees<'a> { @@ -37,11 +37,11 @@ pub trait BinaryTreesMutable<'a>: BinaryTrees<'a> { tl: Self::Tree, key: KeyRc<'a, Self>, tr: Self::Tree, - ) -> Wrapped<'a, Self, NodeRc<'a, Self>>; - fn join(&self, tl: Self::Tree, tr: Self::Tree) -> Wrapped<'a, Self, TreeRc<'a, Self>>; + ) -> BTWrap<'a, Self, NodeRc<'a, Self>>; + fn join(&self, tl: Self::Tree, tr: Self::Tree) -> BTWrap<'a, Self, TreeRc<'a, Self>>; fn split_key( &self, tree: Self::Tree, key: KeyRc<'a, Self>, - ) -> Wrapped<'a, Self, KeySplit<'a, Self>>; + ) -> BTWrap<'a, Self, KeySplit<'a, Self>>; }