RosettaCodeData/Task/Queue-Definition/Fantom/queue-definition.fantom
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

24 lines
337 B
Text

class Queue
{
List queue := [,]
public Void push (Obj obj)
{
queue.add (obj) // add to right of list
}
public Obj pop ()
{
if (queue.isEmpty)
throw (Err("queue is empty"))
else
{
return queue.removeAt(0) // removes left-most item
}
}
public Bool isEmpty ()
{
queue.isEmpty
}
}