diff options
Diffstat (limited to '')
-rw-r--r-- | src/main.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 9cf9492..59642d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,19 @@ impl<T: Ord> AVLTreeSet<T> { Self { root: None } } + pub fn find(self, value: T) -> bool { + let mut current_tree = &self.root; + + while let Some(current_node) = current_tree { + match current_node.value.cmp(&value) { + Ordering::Less => current_tree = ¤t_node.right, + Ordering::Equal => return true, + Ordering::Greater => current_tree = ¤t_node.left, + } + } + + false + } pub fn insert(&mut self, value: T) -> bool { let mut current_tree = &mut self.root; |