From a1d836ed545a1e121298cef18b6c4a25dd599d72 Mon Sep 17 00:00:00 2001 From: timofey Date: Sun, 18 Jun 2023 12:55:18 +0000 Subject: [PATCH] `BinaryTreesHeight::node_height_error` --- src/flow/binary.rs | 1 + src/flow/binary/balancing.rs | 4 ++++ src/flow/binary/bound.rs | 4 ++++ src/mrds/trees/heighted.rs | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/src/flow/binary.rs b/src/flow/binary.rs index dd8195c..06693ab 100644 --- a/src/flow/binary.rs +++ b/src/flow/binary.rs @@ -135,6 +135,7 @@ pub trait BinaryTreesMutable<'a>: BinaryTreesEmpty<'a> + BinaryTreesTreeOf<'a> { pub trait BinaryTreesHeight<'a>: BinaryTrees<'a> { fn height(&self, tree: &Self::Tree) -> u64; fn leaf_height_error(&self, height: u64) -> BTWrap<'a, Self, T>; + fn node_height_error(&self) -> BTWrap<'a, Self, T>; } pub trait BinaryTreesTryJoin<'a>: BinaryTrees<'a> { diff --git a/src/flow/binary/balancing.rs b/src/flow/binary/balancing.rs index 0df0eb6..a8b95b7 100644 --- a/src/flow/binary/balancing.rs +++ b/src/flow/binary/balancing.rs @@ -163,6 +163,10 @@ impl<'a, BT: BinaryTreesUnbalanced<'a>> BinaryTreesHeight<'a> for BalancedTrees< fn leaf_height_error(&self, height: u64) -> BTWrap<'a, Self, T> { self.0.leaf_height_error(height) } + + fn node_height_error(&self) -> BTWrap<'a, Self, T> { + self.0.node_height_error() + } } impl<'a, BT: BinaryTreesUnbalanced<'a> + BinaryTreesTryJoin<'a>> BinaryTreesTryJoin<'a> diff --git a/src/flow/binary/bound.rs b/src/flow/binary/bound.rs index 0bf5ff0..72b7bf9 100644 --- a/src/flow/binary/bound.rs +++ b/src/flow/binary/bound.rs @@ -172,6 +172,10 @@ impl<'a, BT: BinaryTreesBindable<'a> + BinaryTreesHeight<'a>> BinaryTreesHeight< fn leaf_height_error(&self, height: u64) -> BTWrap<'a, Self, T> { self.0.leaf_height_error(height) } + + fn node_height_error(&self) -> BTWrap<'a, Self, T> { + self.0.node_height_error() + } } impl<'a, BT: BinaryTreesBindable<'a> + BinaryTreesTryJoin<'a>> BinaryTreesTryJoin<'a> diff --git a/src/mrds/trees/heighted.rs b/src/mrds/trees/heighted.rs index d1172c9..5822f2c 100644 --- a/src/mrds/trees/heighted.rs +++ b/src/mrds/trees/heighted.rs @@ -122,6 +122,10 @@ impl<'a, A: 'a + Ord + Clone> BinaryTreesHeight<'a> for Trees { fn leaf_height_error(&self, height: u64) -> BTWrap<'a, Self, T> { panic!("leaf height error: {height}.") } + + fn node_height_error(&self) -> BTWrap<'a, Self, T> { + panic!("node with height 0.") + } } impl<'a, A: 'a + Ord + Clone> BinaryTreesEmpty<'a> for Trees {