Chapter 3 QUEUES 1. Specifications for Queues 2. Implementation of Queues L3 Contiguous Queues in C++ L 4. Demonstration and Testing 5. Application: Airport Simulation 6. Pointers and Pitfalls
Chapter 3 QUEUES 1. Specifications for Queues 2. Implementation of Queues 3. Contiguous Queues in C++ 4. Demonstration and Testing 5. Application: Airport Simulation 6. Pointers and Pitfalls
3.1 Specifications for Queue rear A Queue is a data structure in which insertions take place at front one end and deletions take place at the opposite end. 票签 Characteristic: First In first out
A Queue is a data structure in which insertions take place at one end and deletions take place at the opposite end. 3.1 Specifications for Queue Characteristic: First In First Out 2 3 4 1 1 1 2 2 front rear
Queue: Queue; Post: The queue has been created and is initialized to be empty Error code Queue append (const Queue entry &x) Post: If there is space, x is added to the queue as its rear. otherwise an error code of overflow is returned
Queue :: Queue( ); Post: The Queue has been created and is initialized to be empty. Error_code Queue :: append(const Queue entry &x); Post: If there is space, x is added to the Queue as its rear.Otherwise an Error code of overflow is returned
Error code Queue serve(; Post: If the Queue is not empty, the front of the Queue has been removed otherwise an error code of underflow is returned Error code Queue: retrieve Queue entry &x)const Post: If the Queue is not empty the front of the Queue has been recorded as x. otherwise an Error code of underflow is returned
Error_code Queue :: serve( ); Post: If the Queue is not empty, the front of the Queue has been removed. Otherwise an Error code of underflow is returned. Error_code Queue::retrieve(Queue entry &x) const; Post: If the Queue is not empty, the front of the Queue has been recorded as x. Otherwise an Error code of underflow is returned
bool Queue empty()const; Post: Return true if the Queue is empty, otherwise return false Extended Queues class Extended queue: public Queue i public: bool full()const; int size const void clear; Error code serve and retrieve Queue entry &item
bool Queue :: empty( ) const; Post: Return true if the Queue is empty, otherwise return false. Extended Queues class Extended queue: public Queue { public: bool full( ) const; int size( ) const; void clear( ); Error_code serve and retrieve(Queue entry &item); };