Queue

From DmWiki

This article is a stub. You can help improve the article by expanding it.


A queue in programming terms is a data type that follows FIFO order rules. i.e. First In First Out. This is like going to the cinema and standing in a queue; you are not allowed to push in you must wait until those in front of you are served and given their tickets. When using queues you can't normally access items in the middle as they have to wait their turn behind earlier entrants. Clients can place/remove data into/from the queue. The data that has been in the queue longest is always first in the queue. Data reaching the front of the queue is removed from the queue and given to the calling process. A queue usually ignores or throws an exception if an attempt is made to access data that is not first in line. In Object Oriented languages a queue is sometimes known as an ADT or Abstract Data Type, as objects can be built, which inherit its FIFO properties.

STL implementation: std::queue (http://www.sgi.com/tech/stl/queue.html)


Special Type of Queue

Priority Queue 
Queue which have priority parameter attach with each element. The element that has higher priority will move to the front of the lower one. The example of this type is OS multi thread process, where interrupt processes have the highest priority and alway process before application processes
DevMaster navigation