Insert all elements at a given position, following elements are shifted.

var a = [10, 20, 30, 40]
a.insert_all([100..102], 2)
assert a      ==  [10, 20, 100, 101, 102, 30, 40]

REQUIRE index >= 0 and index <= length

ENSURE self[index] == coll.first

Property definitions

core $ Sequence :: insert_all
	# Insert all elements at a given position, following elements are shifted.
	#
	#     var a = [10, 20, 30, 40]
	#     a.insert_all([100..102], 2)
	#     assert a      ==  [10, 20, 100, 101, 102, 30, 40]
	#
	# REQUIRE `index >= 0 and index <= length`
	# ENSURE `self[index] == coll.first`
	fun insert_all(coll: Collection[E], index: Int)
	do
		assert index >= 0 and index < length
		if index == length then
			add_all(coll)
		end
		for c in coll do
			insert(c, index)
			index += 1
		end
	end
lib/core/collection/abstract_collection.nit:1210,2--1228,4

core $ AbstractArray :: insert_all
	redef fun insert_all(coll, pos)
	do
		var l = coll.length
		if l == 0 then return
		enlarge(length + l)
		_length += l
		copy_to(pos, length-pos-l, self, pos + l)
		for c in coll do
			self[pos] = c
			pos += 1
		end
	end
lib/core/collection/array.nit:252,2--263,4

pthreads $ ConcurrentSequence :: insert_all
	redef fun insert_all(from, pos)
	do
		mutex.lock
		real_collection
		mutex.unlock
	end
lib/pthreads/concurrent_collections.nit:319,2--324,4

pthreads :: redef_collections $ Array :: insert_all
	redef fun insert_all(from, pos)
	do
		mutex.lock
		super
		mutex.unlock
	end
lib/pthreads/redef_collections.nit:84,2--89,4