Length of the array is extracted using the field $len in the $Liststruct.
Array push is implemented similar to the array_grow() method of nBallerina.
Array is created with a minimum capacity of 4.
If the capacity equals the length of the array, new array is created with a capacity of 1.5 times the previous capacity and the values in the existing array is copied to it. Then the reference of the $arr in the $List struct is changed.
Length of the array is extracted using the field
$len
in the$List
struct. Array push is implemented similar to thearray_grow()
method of nBallerina. Array is created with a minimum capacity of 4. If the capacity equals the length of the array, new array is created with a capacity of 1.5 times the previous capacity and the values in the existing array is copied to it. Then the reference of the$arr
in the$List
struct is changed.