Axle v0.14.1
Package

std/collections/arraylist

std/collections/arraylist — generic growable array ArrayList<T>.

Pure-Axle dynamic array over the four mono dimensions
(i32 / i64 / f64 / string). Each instantiation is fully
monomorphised, so ArrayList<i32> and ArrayList<string> carry no
virtual dispatch and inline cleanly at call sites.

Backing store:

data : T[cap] — libc_malloc allocation addressed as a T[],
the first len slots hold the live elements.
len : i64 — element count.
cap : i64 — allocated slot count; doubles when len hits it.

add is amortised O(1) (geometric growth ×2). get returns
T | null — null for an out-of-range index, so get(i) ?? fallback
is the idiomatic checked read. set / removeAt bound-check and
raise IndexOutOfBoundsException (a write to a missing slot is a
programming error, not an absent value). indexOf / contains scan
with ==; for T = f64 a NaN element is never found (NaN != NaN),
matching the semantics of Axle's float comparison.

The data array is a dynamic array — the compiler's auto-free
transform releases the old buffer after a grow (the resized copy
is kept) and the live buffer when the list itself is dropped.

Free functions

TypeMethod and description
i64
__floorLog2(n : i64) : i64 floor(log2 n) for n >= 1 — the base of the introsort recursion-depth
budget, past which a range falls to heapsort.

Method detail

#__floorLog2

__floorLog2(n : i64) : i64

floor(log2 n) for n >= 1 — the base of the introsort recursion-depth
budget, past which a range falls to heapsort.

C class ArrayList<T>

Constructors

TypeMethod and description
constructor() Build an empty list with an 8-slot backing buffer pre-allocated,
so the first eight adds grow nothing.

Method detail

#constructor

constructor()

Build an empty list with an 8-slot backing buffer pre-allocated,
so the first eight adds grow nothing.

Methods

Method detail

#size

size(self) : i32

#reserve

reserve(mut self, capacity : i64) : void

#isEmpty

isEmpty(self) : bool

#clear

clear(mut self) : void

#add

add(mut self, value : T) : bool

#get

get(self, index : i32) : T | null

#set

set(mut self, index : i32, value : T) : T ! IndexOutOfBoundsException

#removeAt

removeAt(mut self, index : i32) : T ! IndexOutOfBoundsException

#indexOf

indexOf(self, value : T) : i32

#contains

contains(self, value : T) : bool

#sort

sort(mut self) : void

#sortDescending

sortDescending(mut self) : void

#sort

sort(mut self, dir : Sort) : void