tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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