Queue
var/LinkedListNode/head
var/LinkedListNode/tail
New()
head = null
tail = null
proc/Enqueue(d)
if(!tail)
ASSERT(!head)
if(!head)
head = new(d)
tail = head
else
tail = tail.Add(d)
proc/Dequeue()
ASSERT(head)
. = head.data
head = head.next
if(!head)
tail = null
proc/IsEmpty()
return head != null
LinkedListNode
var/data
var/LinkedListNode/next
New(d)
data = d
next = null
proc/Count
. = 0;
for(var/LinkedListNode/i = src; i.next; i = i.next)
.++;
proc/Add(d)
var/LinkedListNode/i = src
while(i.next)
i = i.next
i.next = new(d)
return i.next |