/***************************************** * Instructions * - Replace 'uwuserid' with your uWaterloo User ID * - Select the current calendar term and enter the year * - List students with whom you had discussions and who helped you * * uWaterloo User ID: uwuserid @uwaterloo.ca * Submitted for ECE 250 * Department of Electrical and Computer Engineering * University of Waterloo * Calender Term of Submission: (Winter|Spring|Fall) 201N * * By submitting this file, I affirm that * I am the author of all modifications to * the provided code. * * The following is a list of uWaterloo User IDs of those students * I had discussions with in preparing this project: * - * * The following is a list of uWaterloo User IDs of those students * who helped me with this project (describe their help; e.g., debugging): * - *****************************************/ #ifndef B_TREE_NODE_H #define B_TREE_NODE_H #ifndef nullptr #define nullptr 0 #endif #include "ece250.h" #include "Exception.h" template class B_tree; template class B_tree_node { private: const static int N; int num_elements; bool is_leaf; Type elements[5]; B_tree_node *subtrees[5]; public: B_tree_node( bool = true ); B_tree_node( B_tree_node *, B_tree_node *); ~B_tree_node(); Type retrieve( int ) const; B_tree_node *subtree( int ) const; int size() const; bool leaf() const; bool empty() const; bool full() const; int count( Type const & ) const; void draw( int = 0 ) const; static void space( int = 0 ); B_tree_node *insert( Type const & ); }; template const int B_tree_node::N = 5; template B_tree_node::B_tree_node( bool lf ): num_elements( 0 ), is_leaf( lf ) { // Empty constructor } template B_tree_node::B_tree_node( B_tree_node *first, B_tree_node *second ): num_elements( 2 ), is_leaf( false ) { } template B_tree_node::~B_tree_node() { } template bool B_tree_node::leaf() const { return true; } template int B_tree_node::size() const { return 0; } template bool B_tree_node::full() const { return false; } template bool B_tree_node::empty() const { return true; } template int B_tree_node::count( Type const &obj ) const { return 0; } template Type B_tree_node::retrieve( int n ) const { return Type(); } template B_tree_node *B_tree_node::subtree( int n ) const { return 0; } template B_tree_node *B_tree_node::insert( Type const &obj ) { return 0; } template void B_tree_node::draw( int n ) const { if ( leaf() ) { space( n ); std::cout << "(" << num_elements << ") "; for ( int i = 0; i < num_elements; ++i ) { std::cout << elements[i] << " "; } std::cout << std::endl; } else { space( n ); std::cout << "(" << num_elements << ")" << std::endl; space( n ); std::cout << "*->" << std::endl; subtrees[0]->draw( n + 1 ); for ( int i = 1; i < num_elements; ++i ) { space( n ); std::cout << elements[i] << "-> " << std::endl; subtrees[i]->draw( n + 1 ); } } } template void B_tree_node::space( int n ) { for ( int i = 0; i < n; ++i ) { std::cout << " "; } } #endif