Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Queue-Definition/Fantom/queue-definition.fantom
Normal file
24
Task/Queue-Definition/Fantom/queue-definition.fantom
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue