public class ArrayList<T> extends Object implements List<T>
Resizable array list.
Bulk insertion captures its source before changing the list, so inserting the list into itself is supported. Primitive-specialized targets consume primitive sources without intermediate boxing. Inserting m items shifts the target suffix once: the cost is O(m + suffix length), with O(m) source snapshot storage.
Native operator mapping:
operator[] is mapped to the native klyn_collections_ArrayList_operator_index.import klyn.collections values = [1, 2] values.addAll(1, values) assert values == [1, 1, 2, 2]
| Modifier and Type | Member | Description |
|---|---|---|
| public override readonly native property | sizesize as ULong |
Number of elements in the list. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | ArrayList | Creates an empty ArrayList. |
| public | ArrayListArrayList(collection as Collection<T>) |
Creates an ArrayList from a collection. |
| public | ArrayList | Creates an ArrayList from a read-only list. |
| public | ArrayList | Creates an ArrayList from a set. |
| public | ArrayList | Creates an ArrayList from a tuple. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | addadd(index as Long, item as T) as Void |
Inserts an element at the requested index. |
| public native | addadd(item as T) as Void |
Adds an element at the end. |
| public native | addAll | Inserts every element from a read-only list at the requested index. |
| public native | addAll | Inserts every element from a set at the requested index. |
| public native | addAll | Inserts every element from a tuple at the requested index. |
| public native | addAlladdAll(values as IList<T>) as Void |
Appends every element from a read-only list. |
| public native | addAlladdAll(values as Set<T>) as Void |
Appends every element from a set. |
| public native | addAlladdAll(values as Tuple) as Void |
Appends every element from a tuple. |
| public native | clearclear() as Void |
Removes all elements. |
| public native | countcount(item as T) as ULong |
Counts occurrences of the given element in the list. |
| public native | indexOf | Returns the first index of the given element. |
| public native | join | Joins elements into a single string using the separator. |
| public native | lastIndexOf | Returns the last index of the given element. |
| public native | removeremove(item as T) as Boolean |
Removes the first matching element. |
| public native | removeAtremoveAt(index as Long) as Void |
Removes the element at the requested index. |
| public native | reservereserve(capacity as Long) as Void |
Reserves internal storage for at least the requested number of elements. |
| public native | reversereverse() as Void |
Reverses list elements in-place. |
| public native | reverseNewreverseNew() as ArrayList<T> |
Returns a new reversed list without modifying the original. |
| public native | shuffleshuffle() as Void |
Randomly shuffles the list in-place. |
| public native | sortsort() as Void |
Sorts the list in ascending order. |
| public native | sortNewsortNew() as ArrayList<T> |
Returns a new sorted ArrayList without modifying the original. |
| public override native | toStringtoString() as String |
Returns a string representation of the list. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | operator in(item as T) as Boolean | Returns true if the list contains the given element. |
| public native static | operator+(readonly notnull left as ArrayList<T>, readonly notnull right as ArrayList<T>) as ArrayList<T> | Concatenates two ArrayList instances into a new ArrayList. |
| public native | operator+=(values as IList<T>) as Void | Appends every element from a read-only list. |
| public native | operator+=(values as Set<T>) as Void | Appends every element from a set. |
| public native | operator+=(values as Tuple) as Void | Appends every element from a tuple. |
| public native | operator[](index as Long) as T | Gets the element at the given index. |