Queues

A queue is somewhat similar to a stack but it works on a FIFO (First-In First-Out) basis. The value that is put in the queue first is also the first to be removed from it. It works like a queue in a shop. The person who is first in a queue is served first. Queues are typically used to store things that still need to be done but there are many other uses. The following functions exist (note that the first five are equivalent to the functions for stacks; all data structures have these five functions).
ds_queue_create() Creates a new queue. The function returns an integer as an id that must be used in all other functions to access the particular queue. You can create multiple queues.
ds_queue_destroy(id) Destroys the queue with the given id, freeing the memory used. Don't forget to call this function when you are ready with the structure.
ds_queue_clear(id) Clears the queue with the given id, removing all data from it but not destroying it.
ds_queue_copy(id,source) Copies the queue source into the queue with the given id.
ds_queue_size(id) Returns the number of values stored in the queue.
ds_queue_empty(id) Returns whether the queue is empty. This is the same as testing whether the size is 0.
ds_queue_enqueue(id,val) Enters the value in the queue.
ds_queue_dequeue(id) Returns the value that is longest in the queue and removes it from the queue.
ds_queue_head(id) Returns the value at the head of the queue, that is, the value that has been the longest in the queue. (It does not remove it from the queue.)
ds_queue_tail(id) Returns the value at the tail of the queue, that is, the value that has most recently been added to the queue. (It does not remove it from the queue.)
ds_queue_write(id) Turns the data structure into a string and returns this string. The string can then be used to e.g. save it to a file. This provides an easy mechanism for saving data structures.
ds_queue_read(id,str) Reads the data structure from the given string (as created by the previous call).
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)