BinaryTreesAvl
for BoundTrees
This commit is contained in:
parent
03b4a4764b
commit
1c589acd85
@ -129,3 +129,34 @@ impl<'a, BT: BinaryTreesBindable<'a> + BinaryTreesEmpty<'a>> BinaryTreesEmpty<'a
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, BT: BinaryTreesBindable<'a> + BinaryTreesAvl<'a>> BinaryTreesAvl<'a> for BoundTrees<BT> {
|
||||
fn height(&self, tree: &Self::Tree) -> u64 {
|
||||
self.0.height(&tree.bound)
|
||||
}
|
||||
|
||||
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T> {
|
||||
self.0.leaf_height_error(height)
|
||||
}
|
||||
|
||||
fn join_key_unbalanced(
|
||||
&self,
|
||||
tl: Self::Tree,
|
||||
key: Self::Key,
|
||||
tr: Self::Tree,
|
||||
) -> BTWrap<'a, Self, Self::Node> {
|
||||
let (boundsl, boundsr) = (tl.bounds, tr.bounds);
|
||||
match Bounds::join(boundsl.clone(), boundsr.clone(), &key, self.comparator()) {
|
||||
Ok(bounds) => Self::fmap(
|
||||
self.0.join_key_unbalanced(tl.bound, key, tr.bound),
|
||||
|node| BoundNode2 {
|
||||
boundsl,
|
||||
boundsr,
|
||||
bounds,
|
||||
node,
|
||||
},
|
||||
),
|
||||
Err(e) => self.0.bounds_error(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user