List¶
Import: import system.collections;
Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.
List¶
A growable, ordered sequence with zero-based indexed access. Adding elements may increase its capacity.
constructor¶
Allocates an empty list with an initial backing buffer capacity (defaults to 8).
length¶
Number of elements currently stored.
is_empty¶
True when the list has no elements.
capacity¶
Current capacity of the backing buffer.
reserve¶
Reserves room for additional elements without changing length or existing values.
push¶
Appends a value to the end, growing if necessary.
push_all¶
Appends every element of items in order.
constructor¶
Creates a list containing the elements of items in order. List literals such as [1, 2, 3] create lists in the same way.
take_array¶
Returns the elements as an array and leaves the list empty. The returned array has exactly the previous list length.
this¶
Returns the element at index. Panics if index is out of range.
this¶
Overwrites the element at index. Panics if index is out of range.
pop¶
Removes and returns the last element, or None if the list is empty.
contains¶
True if value is present (uses value equality, including string contents).
index_of¶
Index of the first matching element (by value equality), or None if absent.
last_index_of¶
Index of the last matching element (by value equality), or None if absent.
reverse¶
Reverses the live prefix in place.
slice¶
Returns a new list holding the elements from start (inclusive) to end (exclusive). Panics unless 0 <= start <= end <= length.
concat¶
A new list with this list's elements followed by other.
clone¶
A shallow copy of the live elements.
join¶
Joins stringifiable elements with sep (same conversion as to_string uses). Single pass into a StringBuilder — O(total output), never the quadratic accumulate-and-recopy shape.
clear¶
Removes all elements and releases the references they held. Capacity is unchanged.
clear¶
Removes all elements and releases the references they held. Capacity is unchanged.
insert¶
Inserts value at index, shifting later elements right. index == length appends. Returns false and leaves the list unchanged when index is outside 0 through length.