Page 1 of 1
what is a queue
Posted: Sat Oct 23, 2004 11:21 pm
by phoggy
Hi,
Could someone briefly explain what a queue is and why I would use it instead of an array.
Thanks.
Posted: Sun Oct 24, 2004 2:52 am
by m3mn0n
Dictionary.com/queue wrote:
1. A sequence of stored data or programs awaiting processing.
2. A data structure from which the first item that can be retrieved is the one stored earliest.
So to place things in a queue instead of an array is good if you have to do something with that data that would take up a lot of server resources. To save resources, place them in a queue (in our case, a database) and then schedule, or rotate one after another between them.
The term is also used interchangeably with
cache.
Dictionary.com/cache wrote:To hide or store in a cache.
A good example of using a cache is when you have to send out multiple thousand of e-mails. Instead of sending them all at the same time, you can cache 75% of the list, and then work through the list in quarters to reduce the server load.
Hope this clears things up.
Posted: Sun Oct 24, 2004 5:43 am
by kettle_drum
You may also hear them refered to as FIFO - First In First Out. So that the first item that you place in it, will come out of it first - unlike a stack which is FILO - First In Last Out.
Posted: Tue Oct 26, 2004 6:39 am
by phpScott
The great UK past time.

Posted: Tue Oct 26, 2004 8:32 am
by hokiecsgrad
One of the more important distinctions between an array and a queue, which hasn't specifically been stated yet, is that an array is a random access structure while a queue (and the aforementioned stack) can only be accessed at the "top" or at the "bottom" of the structure.
Basically, queues and stacks are just special types of arrays.