Take and return all elements until the queue is empty.

Ensure:

  • is_empty
  • result.length == old(length)
  • not old(is_empty) implies result.first == old(peek)
var a = (new Array[Int]).as_lifo
a.add 1
a.add 2
a.add 3
assert a.take_all == [3, 2, 1]
assert a.is_empty

Property definitions

core $ Queue :: take_all
	# Take and return all elements until the queue is empty.
	#
	# Ensure:
	# * `is_empty`
	# * `result.length == old(length)`
	# * `not old(is_empty) implies result.first == old(peek)`
	#
	# ~~~
	# var a = (new Array[Int]).as_lifo
	# a.add 1
	# a.add 2
	# a.add 3
	# assert a.take_all == [3, 2, 1]
	# assert a.is_empty
	# ~~~
	fun take_all: Array[E]
	do
		var res = new Array[E]
		while not is_empty do res.add take
		return res
	end
lib/core/queue.nit:77,2--97,4