core :: AbstractArray :: enlarge
cap
The capacity of the array is an internal information. However, this method can be used to prepare a large amount of add
# 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
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
redef fun enlarge(cap) do mutex.lock super mutex.unlock end
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
redef fun enlarge(cap) do mutex.lock real_collection.enlarge(cap) mutex.unlock end