Brett 2023-01-10 22:21:23 -05:00
parent 7ca975d6a0
commit 5d76457678
1 changed files with 9 additions and 8 deletions

View File

@ -107,17 +107,18 @@ namespace blt {
node_binary_search_tree() { node_binary_search_tree() {
m_root = new BST_node(); m_root = new BST_node();
} }
void insert(const T& element) { inline void insert(const T& element) {
insert(m_root, element); insert(m_root, element);
} }
[[nodiscard]] BST_node* search(const T& element) const { [[nodiscard]] inline BST_node* search(const T& element) const {
return search(nullptr, element); BST_node parent;
return search(&parent, element);
} }
void remove(const T& element) { void remove(const T& element) {
BST_node* parent = nullptr; BST_node* parent {};
BST_node* elementNode = search(parent, element); BST_node* elementNode = search(parent, element);
BST_node*& parentChildSide = parent->left; BST_node*& parentChildSide = parent->left;
@ -142,11 +143,11 @@ namespace blt {
delete(elementNode); delete(elementNode);
} }
std::vector<BST_node*> inOrderTraverse(){ inline std::vector<BST_node*> inOrderTraverse(){
return inOrderTraverse(m_root); return inOrderTraverse(m_root);
} }
BST_node* debug(){ inline BST_node* debug(){
return m_root; return m_root;
} }