/***************************************** * 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 "ece250.h" #include "Exception.h" template class Dynamic_queue { private: int initial_capacity; int array_capacity; Type *array; int ihead; int itail; int entry_count; // other integer member variables, as necessary public: Dynamic_queue( int = 10 ); Dynamic_queue( Dynamic_queue const & ); ~Dynamic_queue(); Type head() const; int size() const; bool empty() const; int capacity() const; void swap( Dynamic_queue & ); Dynamic_queue &operator=( Dynamic_queue ); void enqueue( Type const & ); Type dequeue(); void clear(); // Friends template friend std::ostream &operator<<( std::ostream &, Dynamic_queue const & ); }; template Dynamic_queue::Dynamic_queue( int n ): initial_capacity( std::max( n, 1 ) ), array_capacity( initial_capacity ), array( new Type[initial_capacity] ), ihead( 0 ), itail( initial_capacity - 1 ), entry_count( 0 ) { // Enter your implementation here. } template Dynamic_queue::Dynamic_queue( Dynamic_queue const &queue ): initial_capacity( queue.initial_capacity ), array_capacity( queue.array_capacity ), array( new Type[array_capacity] ), ihead( queue.ihead ), itail( queue.itail ), entry_count( queue.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 Dynamic_queue::~Dynamic_queue() { // Enter your implementation here. } template int Dynamic_queue::size() const { // Enter your implementation here. return 0; } template int Dynamic_queue::capacity() const { // Enter your implementation here. return 0; } template bool Dynamic_queue::empty() const { // Enter your implementation here. return true; } template Type Dynamic_queue::head() const { // Enter your implementation here. return Type(); } template void Dynamic_queue::swap( Dynamic_queue &queue ) { std::swap( initial_capacity, queue.initial_capacity ); std::swap( array_capacity, queue.array_capacity ); std::swap( array, queue.array ); std::swap( ihead, queue.ihead ); std::swap( itail, queue.itail ); std::swap( entry_count, queue.entry_count ); } template Dynamic_queue &Dynamic_queue::operator=( Dynamic_queue rhs ) { swap( rhs ); return *this; } template void Dynamic_queue::enqueue( Type const &obj ) { // Enter your implementation here. } template Type Dynamic_queue::dequeue() { // Enter your implementation here. return Type(); } template void Dynamic_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, Dynamic_queue const &queue ) { // I don't know how you are implementing your queue so I cannot print it. // If you want, you can print whatever you want here and then call cout // in the driver. // Remember to redirect to out, e.g., // out << "Hello!"; return out; } // Is an error showing up in ece250.h or elsewhere? // Did you forget a closing '}' ? #endif