1 / 6

Queues

Queues. CS-240 & CS-341 Dick Steflik. Queues. First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed in their chronological order (oldest first). Applications. discrete event simulation - digital delay line

emery
Télécharger la présentation

Queues

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Queues CS-240 & CS-341 Dick Steflik

  2. Queues • First In, First Out operation - FIFO • As items are added they are chronologically ordered, items are removed in their chronological order (oldest first)

  3. Applications • discrete event simulation - • digital delay line • task scheduling in an operation system • staging area for data acquisition systems • I/O buffers • print queues

  4. Normal methods • constructor - create and initialize a queue object • copy constructor - create a queue object that is a duplicate of another existing queue object (this method is needed to insure correct value semantics) • overloaded assignment operator - assign the value of an existing queue object (a) to another existing queue object (b) so that the result is that b is a duplicate of a (this method is needed to insure correct value semantics) • destructor - destroy a queue object by returning any of its dynamic storage back to the heap and setting its static elements to NULL or zero

  5. Methods • enqueue - add an item (at the back) • dequeue - return the value of the item at the front of the queue then delete the item • isEmpty - return false/true depending if the queue is empty; true if it is, false otherwise

  6. Private data strategies • use an array to hold items and use an int as an index for the array to indicate where the back of the queue is • same as above, but use a dynamic array • same as above but treat array as if it were circular and use two ints, one to indicate the front and the other to indicate the back • use a struct to define a node and add nodes dynamically as they are needed; use one static pointer to a node to point at the fron node and another to point at the back node.

More Related