From 62611ff8c8ac525abf8be231cc7857798b90d13a Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 18 Mar 2025 13:54:57 -0400 Subject: [PATCH] starter set code --- lectures/18_trees_I/ds_set_starter.h | 55 ++-------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/lectures/18_trees_I/ds_set_starter.h b/lectures/18_trees_I/ds_set_starter.h index e146933..91117cb 100644 --- a/lectures/18_trees_I/ds_set_starter.h +++ b/lectures/18_trees_I/ds_set_starter.h @@ -34,7 +34,6 @@ public: // comparison operators are straightforward bool operator==(const tree_iterator& r) { return ptr_ == r.ptr_; } bool operator!=(const tree_iterator& r) { return ptr_ != r.ptr_; } - // increment & decrement will be discussed in Lecture 18 and Lab 11 private: // representation @@ -60,67 +59,21 @@ public: } typedef tree_iterator iterator; - - int size() const { return size_; } - bool operator==(const ds_set& old) const { return (old.root_ == this->root_); } - - // FIND, INSERT & ERASE iterator find(const T& key_value) { return find(key_value, root_); } std::pair< iterator, bool > insert(T const& key_value) { return insert(key_value, root_); } - int erase(T const& key_value) { return erase(key_value, root_); } - - // OUTPUT & PRINTING - friend std::ostream& operator<< (std::ostream& ostr, const ds_set& s) { - s.print_in_order(ostr, s.root_); - return ostr; - } - void print_as_sideways_tree(std::ostream& ostr) const { print_as_sideways_tree(ostr, root_, 0); } - // ITERATORS iterator begin() const { - - - - - - - } + iterator end() const { return iterator(NULL); } private: // REPRESENTATION TreeNode* root_; int size_; - - // PRIVATE HELPER FUNCTIONS - TreeNode* copy_tree(TreeNode* old_root) { /* Implemented in Lab 9 */ } - void destroy_tree(TreeNode* p) { /* Implemented in Lecture 18 */ } - - iterator find(const T& key_value, TreeNode* p) { - - - - - - - - - - } - - std::pair insert(const T& key_value, TreeNode*& p) { /* Discussed in Lecture 18 */ } - int erase(T const& key_value, TreeNode* &p) { /* Implemented in Lecture 19 */ } - - void print_in_order(std::ostream& ostr, const TreeNode* p) const { - if (p) { - print_in_order(ostr, p->left); - ostr << p->value << "\n"; - print_in_order(ostr, p->right); - } - } - - void print_as_sideways_tree(std::ostream& ostr, const TreeNode* p, int depth) const { + iterator find(const T& key_value, TreeNode* p) { /* to be implemented */ } + std::pair insert(const T& key_value, TreeNode*& p) { /* to be implemented */ } + void destroy_tree(TreeNode* p) { /* to be implemented */ } }; #endif