From 184a2563e0f94af9791ae6482e4f3803c9242b5d Mon Sep 17 00:00:00 2001 From: Datawater <86855332+datawater@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:55:18 +0400 Subject: [PATCH] Remove tree implementation --- src/pgn/mod.rs | 2 -- src/pgn/tree.rs | 63 ------------------------------------------------- 2 files changed, 65 deletions(-) delete mode 100644 src/pgn/tree.rs diff --git a/src/pgn/mod.rs b/src/pgn/mod.rs index 1ad910a..f671561 100644 --- a/src/pgn/mod.rs +++ b/src/pgn/mod.rs @@ -1,6 +1,4 @@ pub mod ast; -mod tree; - pub use ast::*; use std::collections::VecDeque; diff --git a/src/pgn/tree.rs b/src/pgn/tree.rs deleted file mode 100644 index c9e1ba4..0000000 --- a/src/pgn/tree.rs +++ /dev/null @@ -1,63 +0,0 @@ -#[derive(Debug, PartialEq, Eq)] -pub struct Tree { - // NOTE: Using a whole ass vec here feels a bit icky - // TODO(#5): (MAYBE) Replace this with a smaller vec, or make the user suply a vec-like type - children: Vec>>, - value: T, -} - -#[allow(dead_code)] -impl Tree { - #[inline(always)] - pub fn new() -> Self { - return Tree { - children: Vec::new(), - value: unsafe { std::mem::zeroed() }, - }; - } - - #[inline(always)] - pub fn new_with_value(v: T) -> Self { - return Tree { - children: Vec::new(), - value: v, - }; - } - - #[inline(always)] - pub fn append(&mut self, v: T) { - self.children.push(Box::new(Self::new_with_value(v))); - } - - #[inline(always)] - pub fn insert(&mut self, v: T) -> &mut Box> { - self.append(v); - - self.children.last_mut().unwrap() - } - - #[inline(always)] - pub fn get_value(&self) -> &T { - return &self.value; - } - - #[inline(always)] - pub fn get_value_mut(&mut self) -> &mut T { - return &mut self.value; - } - - #[inline(always)] - pub fn is_leaf(&self) -> bool { - return self.children.len() == 0; - } - - #[inline(always)] - pub fn get_children(&self) -> &Vec>> { - return &self.children; - } - - #[inline(always)] - pub fn get_children_mut(&mut self) -> &mut Vec>> { - return &mut self.children; - } -}