1 / 12

Queues

Queues. Using arrays... Can populate an array with information... Then remove it as we deal with it. Queues. Have 2 functions... Store data to a queue... Deal with the data in the queue. Examples. Tasks queued by the OS, (Disk Access) Orders queued by a shop Hospital A&E Printer Queue.

willa
Download Presentation

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 • Using arrays... • Can populate an array with information... • Then remove it as we deal with it...

  2. Queues • Have 2 functions... • Store data to a queue... • Deal with the data in the queue

  3. Examples • Tasks queued by the OS, (Disk Access) • Orders queued by a shop • Hospital A&E • Printer Queue

  4. Queues • Usually First in First Out(FIFO) • the first item (next to be used) • also called the head or the front • the last item (where we append additions to the queue) • also called the tail or the back

  5. Queue • Once items are in the Queue they cannot be changed

  6. Queues

  7. Queue Operations • Create Queue • Delete Queue • enQueue • Serve • getHead • getTail • isFull

  8. Create a Queue • We will need... • An array • Variables for the head + tail • An action to add something to the tail... • An action to serve from the head...

  9. Errors • It should: • Throw an error if we try to add to a full queue • Throw an error if we try to remove from an empty queue

  10. Queues Advanced: Cyclic Queue At the moment we have a limited space... Once the queue is used it is done... This can be sorted by looping back around...

  11. Cyclic Buffering

  12. Can we create this... • Need to have a quick algorithm that... • Notices the pointer is at the end of the list • Puts it to the start of the list • Does not over ride any data from the start of the list...

More Related