/***************************************** * 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 DYNAMIC_STACK_AS_ARRAY_H #define DYNAMIC_STACK_AS_ARRAY_H #ifndef nullptr #define nullptr 0 #endif #include #include "Exception.h" template class Dynamic_range_stack { private: int entry_count; int initial_capacity; int array_capacity; Type *stack_array; Type *maximum_array; Type *minimum_array; // You may wish to include a number of other helper functions // in order to abstract out such operations as halving and // doubling the size of the arrays void halve_capacity(); void double_capacity(); public: Dynamic_range_stack( int = 10 ); Dynamic_range_stack( Dynamic_range_stack const & ); ~Dynamic_range_stack(); Type top() const; int size() const; bool empty() const; int capacity() const; Type maximum() const; Type minimum() const; void swap( Dynamic_range_stack & ); Dynamic_range_stack &operator=( Dynamic_range_stack const & ); void push( Type const & ); Type pop(); void clear(); // Friends template friend std::ostream &operator<<( std::ostream &, Dynamic_range_stack const & ); }; template Dynamic_range_stack::Dynamic_range_stack( int n ): entry_count( 0 ), initial_capacity( std::max( 1, n ) ), array_capacity( initial_capacity ), stack_array( new Type[array_capacity] ), maximum_array( new Type[array_capacity] ), minimum_array( new Type[array_capacity] ) { // empty constructor } template Dynamic_range_stack::Dynamic_range_stack( Dynamic_range_stack const &stack ): entry_count( stack.entry_count ), initial_capacity( stack.initial_capacity ), array_capacity( stack.array_capacity ), stack_array( new Type[array_capacity] ), minimum_array( new Type[array_capacity] ), maximum_array( new Type[array_capacity] ) { // The above initializations copy the values of the appropriate // member variables and allocate memory for the data structure; // however, you must still copy the stored objects. // Enter your implementation here. } template Dynamic_range_stack::~Dynamic_range_stack() { // Enter your implementation here. } template Type Dynamic_range_stack::top() const { // Enter your implementation here. return Type(); } template Type Dynamic_range_stack::maximum() const { // Enter your implementation here. return Type(); } template Type Dynamic_range_stack::minimum() const { // Enter your implementation here. return Type(); } template int Dynamic_range_stack::size() const { // Enter your implementation here. return 0; } template bool Dynamic_range_stack::empty() const { // Enter your implementation here. return true; } template int Dynamic_range_stack::capacity() const { // Enter your implementation here. return 0; } template void Dynamic_range_stack::swap( Dynamic_range_stack &stack ) { std::swap( entry_count, stack.entry_count ); std::swap( initial_capacity, stack.initial_capacity ); std::swap( array_capacity, stack.array_capacity ); std::swap( stack_array, stack.stack_array ); std::swap( maximum_array, stack.maximum_array ); std::swap( minimum_array, stack.minimum_array ); } template Dynamic_range_stack &Dynamic_range_stack::operator=( Dynamic_range_stack const &rhs ) { Dynamic_range_stack copy( rhs ); swap( copy ); return *this; } template void Dynamic_range_stack::push( Type const &obj ) { // Enter your implementation here. } template Type Dynamic_range_stack::pop() { // Enter your implementation here. return Type(); } template void Dynamic_range_stack::clear() { // Enter your implementation here. } // You can modify this function however you want: it will not be tested template std::ostream &operator<<( std::ostream &out, Dynamic_range_stack const &stack ) { // Print out your stacks return out; } // Is an error showing up in ece250.h or elsewhere? // Did you forget a closing '}' ? #endif