/***************************************** * 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 LINKED_QUEUE_H #define LINKED_QUEUE_H #ifndef nullptr #define nullptr 0 #endif #include "ece250.h" // Replace: 'Single_list' (two changes) with whatever linked-list structure you used in Project 1 // 'Single_node' (two changes) with 'Double_node' if your Project 1 involved doubly linked lists #include "Single_list.h" #include "Exception.h" #include template class Linked_queue { private: static int const ARRAY_CAPACITY = 8; Single_list list; int ifront; int iback; int queue_size; public: Linked_queue(); Linked_queue( Linked_queue const & ); ~Linked_queue(); bool empty() const; int size() const; int list_size() const; Type front() const; void swap( Linked_queue & ); Linked_queue &operator=( Linked_queue ); void push( Type const &obj ); Type pop(); // Friends template friend std::ostream &operator<<( std::ostream &, Linked_queue const & ); }; template Linked_queue::Linked_queue(): queue_size( 0 ) { // Empty constructor } template Linked_queue::Linked_queue( Linked_queue const &queue ): ifront( queue.ifront ), iback( queue.iback ), queue_size( queue.queue_size ) { // enter your implementation here } template Linked_queue::~Linked_queue() { // } template bool Linked_queue::empty() const { // enter your implementation here return true; } template int Linked_queue::size() const { // enter your implementation here return 0; } // Do not change this implementation template int Linked_queue::list_size() const { return list.size(); } template Type Linked_queue::front() const { // enter your implementation here return Type(); } template void Linked_queue::swap( Linked_queue &queue ) { std::swap( list, queue.list ); std::swap( queue_size, queue.queue_size ); std::swap( ifront, queue.ifront ); std::swap( iback, queue.iback ); } template Linked_queue &Linked_queue::operator=( Linked_queue rhs ) { swap( rhs ); return *this; } template void Linked_queue::push( Type const &obj ) { // enter your implementation here } template Type Linked_queue::pop() { // enter your implementation here return Type(); } // Do not modify this function template std::ostream &operator<<( std::ostream &out, Linked_queue const &queue ) { if ( queue.list.size() == 0 ) { out << "->0"; } else if ( queue.list.size() == 1 ) { out << "->[ "; for ( int i = queue.ifront; i <= queue.iback; ++i ) { out << queue.list.front()[i] << " "; } out << "]->0"; } else { out << "->"; for ( Single_node *ptr = queue.list.head(); ptr != nullptr; ptr = ptr->next() ) { out << "[ "; if ( ptr == queue.list.head() ) { for ( int i = queue.ifront; i <= Linked_queue::ARRAY_CAPACITY - 1; ++i ) { out << ptr->retrieve()[i] << " "; } } else if ( ptr == queue.list.tail() ) { for ( int i = 0; i <= queue.iback; ++i ) { out << ptr->retrieve()[i] << " "; } } else { for ( int i = 0; i <= Linked_queue::ARRAY_CAPACITY - 1; ++i ) { out << ptr->retrieve()[i] << " "; } } out << "]->"; } out << "0"; } return out; } // Is an error showing up in ece250.h or elsewhere? // Did you forget a closing '}' ? #endif