Add an item before the first one.

var a = [1,2,3]
a.unshift(10)
a.unshift(20)
assert a  == [20,10,1,2,3]

Property definitions

core $ Sequence :: unshift
	# Add an item before the first one.
	#
	#     var a = [1,2,3]
	#     a.unshift(10)
	#     a.unshift(20)
	#     assert a  == [20,10,1,2,3]
	fun unshift(e: E) is abstract
lib/core/collection/abstract_collection.nit:1139,2--1145,30

core $ List :: unshift
	# O(1)
	redef fun unshift(e)
	do
		var node = new ListNode[E](e)
		var head = _head
		if head == null then
			_tail = node
		else
			node.next = head
			head.prev = node
		end
		_head = node
		length += 1
	end
lib/core/collection/list.nit:101,2--114,4

core $ CircularArray :: unshift
	redef fun unshift(item) do
		var l = length + 1
		enlarge(l)
		length = l

		var native = _native
		var h = head - 1
		if h < 0 then h += native.length

		native[h] = item
		head = h
	end
lib/core/collection/circular_array.nit:135,2--146,4

more_collections $ UnrolledList :: unshift
	redef fun unshift(item)
	do
		var node = head_node
		if not node.full then
			if node.head_index > 0 then
				# There's room at the head
				node.head_index -= 1
			else
				# Move everything over by `d`
				assert node.tail_index < node.capacity
				var d = (node.capacity-node.tail_index) / 2 + 1
				node.move_tail(0, d)
				for i in d.times do node.items[node.head_index+i] = null
				node.head_index += d-1
				node.tail_index += d
			end
			node.items[node.head_index] = item
		else
			# New node!
			node = new UnrolledNode[E](nodes_length)
			insert_node(node, null, head_node)
			node.head_index = node.capacity-1
			node.tail_index = node.capacity
			node.items[node.capacity-1] = item
		end
		length += 1
	end
lib/more_collections/more_collections.nit:454,2--480,4

dom $ XMLEntities :: unshift
	redef fun unshift(e) do
		entities.unshift e
		e.set_parent owner
	end
lib/dom/xml_entities.nit:107,2--110,4

core $ AbstractArray :: unshift
	redef fun unshift(item)
	do
		var l = length
		if l > 0 then
			enlarge(l + 1)
			copy_to(0, l, self, 1)
		end
		self[0] = item
	end
lib/core/collection/array.nit:236,2--244,4

pthreads $ ConcurrentSequence :: unshift
	redef fun unshift(e)
	do
		mutex.lock
		real_collection.unshift(e)
		mutex.unlock
	end
lib/pthreads/concurrent_collections.nit:370,2--375,4

pthreads :: redef_collections $ Array :: unshift
	redef fun unshift(e)
	do
		mutex.lock
		super
		mutex.unlock
	end
lib/pthreads/redef_collections.nit:77,2--82,4

pthreads $ ConcurrentList :: unshift
	redef fun unshift(e)
	do
		mutex.lock
		real_collection.unshift(e)
		mutex.unlock
	end
lib/pthreads/concurrent_collections.nit:497,2--502,4

pthreads $ BlockingQueue :: unshift
	redef fun unshift(e) do
		mutex.lock
		real_collection.unshift(e)
		self.cond.signal
		mutex.unlock
	end
lib/pthreads/concurrent_collections.nit:569,2--574,4

actors $ Mailbox :: unshift
	redef fun unshift(e) do
		mutex.lock
		real_collection.unshift(e)
		self.cond.signal
		mutex.unlock
	end
lib/actors/actors.nit:92,2--97,4