Queue

A queue is a data structure that allows insertion and retrieval of data in the FIFO manner, i.e. the first-in first-out order. Since the queue class is defined by extending the cons class, ordinary list functions can be applied to a queue. For example, caar retrieves the next element to be dequeued, and cadr gets the element that is queued most recently.




queue [class]


  :super   cons 

:slots (car cdr)


defines queue (FIFO) objects.


:init [method]

initializes the queue to have no elements.


:enqueue val [method]

puts val in the queue as the most recent element.


:dequeue &optional (error-p nil) [method]

retrieves the oldest value in the queue, and removes it of the queue. If the queue is empty, it reports an error when error-p is non-nil, or returns NIL otherwise.


:empty? [method]

returns T if the queue is empty.


:length [method]
returns the length of the queue.


k-okada 2013-05-21