Remove the first item.

The second item thus become the first.

var a = [1,2,3]
assert a.shift  == 1
assert a.shift  == 2
assert a == [3]

REQUIRE not is_empty

Property definitions

core $ Sequence :: shift
	# Remove the first item.
	# The second item thus become the first.
	#
	#     var a = [1,2,3]
	#     assert a.shift  == 1
	#     assert a.shift  == 2
	#     assert a == [3]
	#
	# REQUIRE `not is_empty`
	fun shift: E is abstract
lib/core/collection/abstract_collection.nit:1156,2--1165,25

core $ List :: shift
	# O(1)
	redef fun shift
	do
		var node = _head.as(not null)
		_head = node.next
		node.next = null
		if _head == null then
			_tail = null
		else
			_head.as(not null).prev = null
		end
		length -= 1
		return node.item
	end
lib/core/collection/list.nit:161,2--174,4

core $ CircularArray :: shift
	redef fun shift do
		var l = length - 1
		assert l >= 0
		length = l

		var native = _native
		var h = head
		var res = native[h]

		h += 1
		var cap = native.length
		if h >= cap then h -= cap
		head = h

		return res
	end
lib/core/collection/circular_array.nit:148,2--163,4

more_collections $ UnrolledList :: shift
	redef fun shift
	do
		assert not_empty

		var node = head_node
		while node.length == 0 do
			# Delete empty node
			var nullable_node = node.next
			assert is_not_empty: nullable_node != null
			node = nullable_node
			node.prev = null
			self.head_node = node
		end

		var item = node.items[node.head_index]
		node.head_index += 1
		length -= 1
		return item
	end
lib/more_collections/more_collections.nit:502,2--520,4

dom $ XMLEntities :: shift
	redef fun shift do
		var e = entities.shift
		e.set_parent null
		return e
	end
lib/dom/xml_entities.nit:112,2--116,4

core $ AbstractArray :: shift
	redef fun shift
	do
		assert not_empty: not is_empty
		var r = first
		var l = length-1
		copy_to(1, l, self, 0)
		_length = l
		return r
	end
lib/core/collection/array.nit:226,2--234,4

pthreads $ ConcurrentSequence :: shift
	redef fun shift
	do
		mutex.lock
		var r = real_collection.shift
		mutex.unlock
		return r
	end
lib/pthreads/concurrent_collections.nit:362,2--368,4

pthreads :: redef_collections $ Array :: shift
	redef fun shift
	do
		mutex.lock
		var r = super
		mutex.unlock
		return r
	end
lib/pthreads/redef_collections.nit:69,2--75,4

pthreads $ ConcurrentList :: shift
	redef fun shift
	do
		mutex.lock
		var value = real_collection.shift
		mutex.unlock
		return value
	end
lib/pthreads/concurrent_collections.nit:511,2--517,4

pthreads $ BlockingQueue :: shift
	# If empty, blocks until an item is inserted with `push` or `unshift`
	redef fun shift do
		mutex.lock
		while real_collection.is_empty do self.cond.wait(mutex)
		var r = real_collection.shift
		mutex.unlock
		return r
	end
lib/pthreads/concurrent_collections.nit:576,2--583,4

actors $ Mailbox :: shift
	# If empty, blocks until an item is inserted with `push` or `unshift`
	redef fun shift do
		mutex.lock
		if real_collection.is_empty then
			actor.working = false
			sys.active_actors.decrement
			while real_collection.is_empty do self.cond.wait(mutex)
		end
		var r = real_collection.shift
		mutex.unlock
		return r
	end
lib/actors/actors.nit:99,2--110,4