21 lines
471 B
Plaintext
21 lines
471 B
Plaintext
[indent=4]
|
|
/*
|
|
Stack, in Genie, with GLib double ended Queues
|
|
valac stack.gs
|
|
*/
|
|
init
|
|
var stack = new Queue of int()
|
|
|
|
// push
|
|
stack.push_tail(2)
|
|
stack.push_tail(1)
|
|
|
|
// pop (and peek at top)
|
|
print stack.pop_tail().to_string()
|
|
print stack.peek_tail().to_string()
|
|
|
|
// empty
|
|
print "stack size before clear: " + stack.get_length().to_string()
|
|
stack.clear()
|
|
print "After clear, stack.is_empty(): " + stack.is_empty().to_string()
|