Signed-off-by: Jean Privat <jean@pryen.org>
# Force a capacity
fun enlarge(cap: Int)
do
# Force a capacity
fun enlarge(cap: Int)
do
- var old_cap = _capacity
# get a new capacity
if cap < _the_length + 1 then cap = _the_length + 1
if cap <= _capacity then return
# get a new capacity
if cap < _the_length + 1 then cap = _the_length + 1
if cap <= _capacity then return
var new_array = new NativeArray[nullable N](cap)
_array = new_array
var new_array = new NativeArray[nullable N](cap)
_array = new_array
- # clean the new array
- var i = cap - 1
- while i >=0 do
- new_array[i] = null
- i -= 1
- end
-
- if _the_length == 0 then return
- if _capacity <= old_cap then return
-
# Reput items in the array
var node = _first_item
while node != null do
# Reput items in the array
var node = _first_item
while node != null do