Go to the first, previous, next, last section, table of contents.


The Queue Data Type

The queue data type provides a simple FIFO queue. There are two implementations of a queue in Elib, one using macros and one using functions. The names of the functions/macros in the two implementations are the same, but the efficiency of using one or the other vary greatly under different circumstances.

The implementation using macros should be used when you want to byte-compile your own elisp program. This will be most efficient since byte-compiling an elisp function using macros has the same effect as using inline code in C.

To use the queue data type, put the line

(require 'queue-f)

in your own elisp source file if you want to use the implementation using functions or

(require 'queue-m)

if you want to use the implementation using macros. This is the only difference between them, so it is easy to switch between them during debugging.

Not all functions in `queue-m.el' are implemented as macros, only the short ones. This does not make it less recommendable to use the macro version in your compiled code.

The following functions are provided by the queue:

(queue-create)
Create a new empty queue.
(queue-p queue)
Return t if queue is a queue, otherwise return nil.
(queue-enqueue queue element)
Enter element last into queue.
(queue-dequeue queue)
Remove the first element from queue and return it.
(queue-empty queue)
Return t if queue is empty, otherwise return nil.
(queue-first queue)
Return the first element of queue or nil if it is empty. The element is not removed from the queue.
(queue-nth queue n)
Return the nth element of queue, where the first element of queue has number 0. If the length of queue is less than n, return nil. The element is not removed from the queue.
(queue-last queue)
Return the last element of queue or nil if it is empty. The element is not removed from the queue.
(queue-all queue)
Return a list of all elements in queue. Return nil if queue is empty. The oldest element in the queue is the first in the list.
(queue-copy queue)
Return a copy of queue. All entries in queue are also copied.
(queue-length queue)
Return the number of elements in queue.
(queue-clear queue)
Remove all elements from queue.


Go to the first, previous, next, last section, table of contents.