Home /Modules/collections/SLArray.md

SLArray.md

lib/collections/SLArray.md · 43 line(s) · markdown

SLArray

SLArray is a concrete, fixed-capacity, bounds-safe String array in the SLeeLa collections library. It wraps the VM-managed native array primitive (arrayNew/arrayGet/arraySet/arrayLength) behind a forgiving, bounds- checked API. It requires no Generics and no new VM opcodes.

Unlike SLList (a growable list whose logical length tracks appends), SLArray has a fixed logical length equal to its capacity: once allocate(n) is called, every index 0 .. n-1 is addressable and starts as null.

Naming note: the symbol SLArray now has a single definition, in the collections family. The former core.SLArray (which held no array storage) was renamed to SLCoreCell so that SLArray resolves unambiguously.

Operations

Indices are zero-based. Out-of-range reads return null and out-of-range writes return false, rather than trapping, matching the forgiving contract used across the collections family. This first version accepts Strings only.

Example

See SLArrayBasic for an exercise of allocation, bounds behavior, fill/clear, search, reverse, range copy, and conversion to SLList.