#ifndef BINARY_SEARCH_TREE_RECURSIVE_NULL #define BINARY_SEARCH_TREE_RECURSIVE_NULL #ifndef nullptr #define nullptr 0 #endif #include #include "Exception.h" #include "Binary_search_node_recursive_null.h" template class Binary_search_tree { private: Binary_search_node *root_node; Binary_search_node *root() const; public: Binary_search_tree(); ~Binary_search_tree(); bool empty() const; int size() const; int height() const; Type front() const; Type back() const; bool find( Type const & ) const; bool insert( Type const & ); bool erase( Type const & ); void clear(); }; template Binary_search_tree::Binary_search_tree(): root_node( nullptr ) { // empty } template Binary_search_tree::~Binary_search_tree() { root()->clear( root_node ); } template Binary_search_node *Binary_search_tree::root() const { return root_node; } template bool Binary_search_tree::empty() const { return root()->empty(); } template int Binary_search_tree::size() const { return root()->size(); } template int Binary_search_tree::height() const { return root()->height(); } template Type Binary_search_tree::front() const { return root()->front(); } template Type Binary_search_tree::back() const { return root()->back(); } template bool Binary_search_tree::find( Type const &obj ) const { return root()->find( obj ); } template void Binary_search_tree::clear() { root()->clear( root_node ); } template bool Binary_search_tree::insert( Type const &obj ) { return root()->insert( obj, root_node ); } template bool Binary_search_tree::erase( Type const &obj ) { return root()->erase( obj, root_node ); } #endif