"Internally the queue is implemented by a three-element list. The first element is the queue's contents as a list. The second element is a reference to the last element in the list. The third element is the length of the queue."
http://arcfn.com/doc/queue.html I found using car/cdr and indices to mean different things helped me easily read this. (def enq (obj q)
(atomic
(++ q.2)
(if (no q.0)
(= q.1 (= q.0 list.obj))
(= (cdr q.1) list.obj
q.1 (cdr q.1)))
q.0))
(def deq (q)
(atomic (unless (is 0 q.2) (-- q.2))
(pop q.0)))
Should be semantically identical. |