inline heights
All checks were successful
buildbot/cargo fmt (1.71) Build done.
buildbot/cargo doc (1.71) Build done.
buildbot/cargo clippy (1.71) Build done.
buildbot/cargo test (1.65) Build done.
buildbot/cargo clippy (1.65) Build done.

This commit is contained in:
AF 2023-08-11 12:14:16 +00:00
parent a8af77adf0
commit 174ca78e55

View File

@ -92,12 +92,10 @@ pub trait BinaryTreesAvl<'a>:
key: Self::Key,
tr: Self::Tree,
) -> BTWrap<'a, Self, Self::Node> {
let (hl, hr) = (self.height(&tl), self.height(&tr));
match balancing(hl, hr) {
match balancing(self.height(&tl), self.height(&tr)) {
Balancing::Balanced => self.try_join(tl, key, tr),
Balancing::RightBiased => self.assume_bind(&tr, |ctx, trl, kr, trr| {
let (hrl, hrr) = (ctx.height(&trl), ctx.height(&trr));
if hrl > hrr {
if ctx.height(&trl) > ctx.height(&trr) {
ctx.assume_bind(&trl, |ctx, trll, krl, trlr| {
ctx.make_node((T(tl), key, T(trll)), krl, (T(trlr), kr, T(trr)))
})
@ -106,8 +104,7 @@ pub trait BinaryTreesAvl<'a>:
}
}),
Balancing::LeftBiased => self.assume_bind(&tl, |ctx, tll, kl, tlr| {
let (hll, hlr) = (ctx.height(&tll), ctx.height(&tlr));
if hll < hlr {
if ctx.height(&tll) < ctx.height(&tlr) {
ctx.assume_bind(&tlr, |ctx, tlrl, klr, tlrr| {
ctx.make_node((T(tll), kl, T(tlrl)), klr, (T(tlrr), key, T(tr)))
})