/***************************************** * 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 STABLE_BINARY_HEAP_H #define STABLE_BINARY_HEAP_H #ifndef nullptr #define nullptr 0 #endif #include "ece250.h" #include "Exception.h" #include template class Stable_binary_heap { private: int heap_capacity; Type *array; int *key_array; int heap_size; int key_count; public: Stable_binary_heap( int = 10 ); Stable_binary_heap( Stable_binary_heap const & ); ~Stable_binary_heap(); Stable_binary_heap &operator=( Stable_binary_heap const & ); // Accessors int size() const; int capacity() const; bool empty() const; bool full() const; Type top() const; Type retrieve( int ) const; int key( int ) const; int count( Type const & ) const; // Mutators void push( Type const & ); Type pop(); void clear(); // Friends template friend std::ostream &operator<<( std::ostream &, Stable_binary_heap const & ); }; template Stable_binary_heap::Stable_binary_heap( int n ): heap_capacity( n + 1 ), array( new Type[heap_capacity] ), key_array( new int[heap_capacity] ), heap_size( 0 ), key_count( 0 ) { // empty constructor } template Stable_binary_heap::Stable_binary_heap( Stable_binary_heap const &heap ): heap_capacity( 0 ), array( 0 ), key_array( 0 ), heap_size( 0 ), key_count( 0 ) { *this = heap; } template Stable_binary_heap::~Stable_binary_heap() { // Your implementation here... } template Stable_binary_heap &Stable_binary_heap::operator=( Stable_binary_heap const &rhs ) { if ( this == &rhs ) { return *this; } // Your implementation here... return *this; } template int Stable_binary_heap::size() const { // Your implementation here... return 0; } template int Stable_binary_heap::capacity() const { // Your implementation here... return 0; } template bool Stable_binary_heap::empty() const { // Your implementation here... return true; } template bool Stable_binary_heap::full() const { // Your implementation here... return false; } template Type Stable_binary_heap::top() const { // Your implementation here... return Type(); } template Type Stable_binary_heap::retrieve( int n ) const { return array[n]; } template int Stable_binary_heap::key( int n ) const { return key_array[n]; } template int Stable_binary_heap::count( Type const &obj ) const { // Your implementation here... return 0; } template void Stable_binary_heap::push( Type const &obj ) { // Your implementation here... } template Type Stable_binary_heap::pop() { // Your implementation here... return Type(); } template void Stable_binary_heap::clear() { // Your implementation here... } // You can modify this function however you want: it will not be tested template std::ostream &operator<<( std::ostream &out, Stable_binary_heap const &heap ) { for ( int i = 1; i <= heap.size(); ++i ) { out << heap.retrieve( i ) << "\t"; } out << std::endl; for ( int i = 1; i <= heap.size(); ++i ) { out << heap.key( i ) << "\t"; } return out; } // Is an error showing up in ece250.h or elsewhere? // Did you forget a closing '}' ? #endif