14 lines
356 B
Text
14 lines
356 B
Text
|
|
require "queue"
|
||
|
|
|
||
|
|
local q = new queue()
|
||
|
|
q:push(1)
|
||
|
|
q:push(2)
|
||
|
|
print($"Queue contains {q:toarray():concat(", ")}")
|
||
|
|
print($"Number of elements in queue = {q:size()}")
|
||
|
|
local item = q:pop()
|
||
|
|
print($"'{item}' popped from the queue")
|
||
|
|
print($"First element is now {q:peek()}")
|
||
|
|
q:clear()
|
||
|
|
print("Queue cleared")
|
||
|
|
print($"Is queue now empty? {q:empty() ? "yes" : "no"}")
|