tree_bind
This commit is contained in:
parent
354c2363c8
commit
ada32fdede
@ -56,6 +56,10 @@ pub trait BinaryTrees<'a>: 'a + Clone {
|
||||
{
|
||||
<Self::T as Fail<_>>::fail(e)
|
||||
}
|
||||
|
||||
fn tree_bind(self, fnode: BTWrap<'a, Self, Self::Node>) -> BTWrap<'a, Self, Self::Tree> {
|
||||
Self::bind(fnode, move |node| self.tree_of(node))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BinaryTreesMutable<'a>: BinaryTrees<'a> {
|
||||
@ -74,7 +78,7 @@ pub trait BinaryTreesMutable<'a>: BinaryTrees<'a> {
|
||||
key: KeyRc<'a, Self>,
|
||||
tr: Self::Tree,
|
||||
) -> BTWrap<'a, Self, Self::Tree> {
|
||||
Self::bind(self.clone().join_key(tl, key, tr), move |n| self.tree_of(n))
|
||||
self.clone().tree_bind(self.join_key(tl, key, tr))
|
||||
}
|
||||
|
||||
fn join(self, tl: Self::Tree, tr: Self::Tree) -> BTWrap<'a, Self, Self::Tree> {
|
||||
@ -143,7 +147,7 @@ pub trait BinaryTreesMutable<'a>: BinaryTrees<'a> {
|
||||
}
|
||||
|
||||
fn add_tree(self, tree: Self::Tree, key: KeyRc<'a, Self>) -> BTWrap<'a, Self, Self::Tree> {
|
||||
Self::bind(self.clone().add(tree, key), move |n| self.tree_of(n))
|
||||
self.clone().tree_bind(self.add(tree, key))
|
||||
}
|
||||
|
||||
fn remove(self, tree: Self::Tree, key: KeyRc<'a, Self>) -> BTWrap<'a, Self, Self::Tree> {
|
||||
@ -178,9 +182,7 @@ pub trait BinaryTreesAvl<'a>: BinaryTrees<'a> {
|
||||
key: KeyRc<'a, Self>,
|
||||
tr: Self::Tree,
|
||||
) -> BTWrap<'a, Self, Self::Tree> {
|
||||
Self::bind(self.clone().join_key_balanced(tl, key, tr), move |node| {
|
||||
self.tree_of(node)
|
||||
})
|
||||
self.clone().tree_bind(self.join_key_balanced(tl, key, tr))
|
||||
}
|
||||
|
||||
fn join_key_balanced(
|
||||
|
Loading…
Reference in New Issue
Block a user