result.take
is pop
.The point of such a proxy is to let the user choose the underling data structure behind the LIFO.
var a = [1, 2, 3]
var q = a.as_lifo
assert q.take == 3
assert q.take == 2
q.add(4)
q.add(5)
assert q.take == 5
assert a == [1, 4]
# Return a LIFO proxy queue (stack) where `result.take` is `pop`.
#
# The point of such a proxy is to let the user choose the underling data structure
# behind the LIFO.
#
# ~~~
# var a = [1, 2, 3]
# var q = a.as_lifo
# assert q.take == 3
# assert q.take == 2
# q.add(4)
# q.add(5)
# assert q.take == 5
# assert a == [1, 4]
# ~~~
fun as_lifo: Queue[E] do return new LifoQueue[E](self)
lib/core/queue.nit:101,2--116,55