Force the capacity to be at least cap.

The capacity of the array is an internal information. However, this method can be used to prepare a large amount of add

Property definitions

core $ AbstractArray :: enlarge
	# Force the capacity to be at least `cap`.
	# The capacity of the array is an internal information.
	# However, this method can be used to prepare a large amount of add
	fun enlarge(cap: Int) is abstract
lib/core/collection/array.nit:211,2--214,34

core $ Array :: enlarge
	redef fun enlarge(cap)
	do
		var c = _capacity
		if cap <= c then return
		while c <= cap do c = c * 2 + 2
		var a = new NativeArray[E](c)
		if _capacity > 0 then _items.as(not null).copy_to(a, _length)
		_items = a
		_capacity = c
	end
lib/core/collection/array.nit:401,2--410,4

pthreads :: redef_collections $ Array :: enlarge
	redef fun enlarge(cap)
	do
		mutex.lock
		super
		mutex.unlock
	end
lib/pthreads/redef_collections.nit:106,2--111,4

core $ Bytes :: enlarge
	redef fun enlarge(sz) do
		if capacity >= sz then return
		persisted = false
		if capacity < 16 then capacity = 16
		while capacity < sz do capacity = capacity * 2 + 2
		var ns = new CString(capacity)
		items.copy_to(ns, length, 0, 0)
		items = ns
	end
lib/core/bytes.nit:600,2--608,4

pthreads $ ConcurrentArray :: enlarge
	redef fun enlarge(cap)
	do
		mutex.lock
		real_collection.enlarge(cap)
		mutex.unlock
	end
lib/pthreads/concurrent_collections.nit:403,2--408,4