From cfd35f38e3c1452325c9072b2c0d67b9d17ecbc7 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 18 Feb 2022 22:42:09 +0000 Subject: [PATCH] Rename pre/post/in order methods --- src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8eeb21e..24e9c29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,7 @@ type HeapNode = Option>>; impl PartialEq for BinarySearchTree { fn eq(&self, other: &Self) -> bool { - self.in_order() == other.in_order() + self.in_order_vec() == other.in_order_vec() } } @@ -73,7 +73,7 @@ impl Clone for BinarySearchTree { impl Display for BinarySearchTree { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self.in_order()) + write!(f, "{:?}", self.in_order_vec()) } } @@ -358,19 +358,19 @@ impl BinarySearchTree { removed_max } - pub fn pre_order(&self) -> Vec<&T> { + pub fn pre_order_vec(&self) -> Vec<&T> { let mut elements: Vec<&T> = Vec::new(); Node::pre_order_vec(&self.root, &mut elements); elements } - pub fn in_order(&self) -> Vec<&T> { + pub fn in_order_vec(&self) -> Vec<&T> { let mut elements: Vec<&T> = Vec::new(); Node::in_order_vec(&self.root, &mut elements); elements } - pub fn post_order(&self) -> Vec<&T> { + pub fn post_order_vec(&self) -> Vec<&T> { let mut elements: Vec<&T> = Vec::new(); Node::post_order_vec(&self.root, &mut elements); elements @@ -808,7 +808,7 @@ mod bst_test { } #[test] - fn pre_order() { + fn get_pre_order_vec() { let mut bst = BinarySearchTree::empty(); bst.insert(3); bst.insert(4); @@ -816,11 +816,11 @@ mod bst_test { bst.insert(1); bst.insert(2); - assert_eq!(bst.pre_order(), vec![&3, &1, &2, &4, &5]); + assert_eq!(bst.pre_order_vec(), vec![&3, &1, &2, &4, &5]); } #[test] - fn in_order() { + fn get_in_order_vec() { let mut bst = BinarySearchTree::empty(); bst.insert(3); bst.insert(4); @@ -828,11 +828,11 @@ mod bst_test { bst.insert(1); bst.insert(2); - assert_eq!(bst.in_order(), vec![&1, &2, &3, &4, &5]); + assert_eq!(bst.in_order_vec(), vec![&1, &2, &3, &4, &5]); } #[test] - fn post_order() { + fn get_post_order_vec() { let mut bst = BinarySearchTree::empty(); bst.insert(3); bst.insert(4); @@ -840,7 +840,7 @@ mod bst_test { bst.insert(1); bst.insert(2); - assert_eq!(bst.post_order(), vec![&2, &1, &5, &4, &3]); + assert_eq!(bst.post_order_vec(), vec![&2, &1, &5, &4, &3]); } #[test]