/***************************************** * 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_DUAL_STACK_H #define DYNAMIC_DUAL_STACK_H #ifndef nullptr #define nullptr 0 #endif #include #include #include "Exception.h" template class Dynamic_dual_stack { private: int initial_capacity; int array_capacity; Type *array; int stack_size[2]; public: Dynamic_dual_stack( int = 10 ); Dynamic_dual_stack( Dynamic_dual_stack const & ); ~Dynamic_dual_stack(); int capacity() const; bool empty( int ) const; int size( int ) const; Type top( int ) const; void swap( Dynamic_dual_stack & ); Dynamic_dual_stack &operator=( Dynamic_dual_stack const & ); void push( int, Type const & ); Type pop( int ); void clear(); // Friends template friend std::ostream &operator<<( std::ostream &, Dynamic_dual_stack const & ); }; template Dynamic_dual_stack::Dynamic_dual_stack( int n ): initial_capacity( std::max( 1, n ) ), array_capacity( initial_capacity ), array( new Type[initial_capacity] ) { // Enter your implementation here. } template Dynamic_dual_stack::Dynamic_dual_stack( Dynamic_dual_stack const &stack ): initial_capacity( stack.initial_capacity ), array_capacity( stack.array_capacity ), array( new Type[array_capacity] ) { stack_size[0] = stack.stack_size[0]; stack_size[1] = stack.stack_size[1]; // 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_dual_stack::~Dynamic_dual_stack() { // Enter your implementation here. } template int Dynamic_dual_stack::capacity() const { // Enter your implementation here. return 0; } template bool Dynamic_dual_stack::empty( int m ) const { // Enter your implementation here. return true; } template int Dynamic_dual_stack::size( int m ) const { // Enter your implementation here. return 0; } template Type Dynamic_dual_stack::top( int m ) const { // Enter your implementation here. return Type(); } template void Dynamic_dual_stack::swap( Dynamic_dual_stack &stack ) { std::swap( initial_capacity, stack.initial_capacity ); std::swap( array_capacity, stack.array_capacity ); std::swap( array, stack.array ); std::swap( stack_size[0], stack.stack_size[0] ); std::swap( stack_size[1], stack.stack_size[1] ); } template Dynamic_dual_stack &Dynamic_dual_stack::operator=( Dynamic_dual_stack const &rhs ) { Dynamic_dual_stack copy( rhs ); swap( copy ); return *this; } template void Dynamic_dual_stack::push( int m, Type const &obj ) { // Enter your implementation here. } template Type Dynamic_dual_stack::pop( int m ) { // Enter your implementation here. return Type(); } template void Dynamic_dual_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_dual_stack const &stack ) { for ( int i = 0; i < stack.capacity(); ++i ) { if ( i < stack.stack_size[0] ) { out << stack.array[i] << " "; } else if ( i >= stack.capacity() - stack.stack_size[1] ) { out << stack.array[i] << " "; } else { out << "- "; } } return out; } // Is an error showing up in ece250.h or elsewhere? // Did you forget a closing '}' ? #endif