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