public class Array<T> extends Object implements IList<T>:
Fixed-size contiguous array.
This collection stores a fixed number of elements. Unlike ArrayList<T>, its length is decided at construction time and cannot change afterwards.
The language also exposes the shorthand syntax T[] for this type and T[n] for array allocation.
import klyn.collections data as UInt[] = UInt[3] data[0] = 10u data[1] = 20u data[2] = 30u print(data) # f:[10, 20, 30] print(data.size) # 3
@param <T> Element type. @since 1.0
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly native property | sizesize as ULong |
Returns the number of elements in the array. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | Array | Creates a new array with a fixed number of elements. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | countcount(item as T) as ULong |
Counts occurrences of the given element. |
| public native | join | Joins array elements into a single string. |
| public native | reversereverse() as Void |
Reverses array elements in-place. |
| public native | reverseNewreverseNew() as Array<T> |
Returns a reversed copy without modifying the current array. |
| public native | sortsort() as Void |
Sorts array elements in-place. |
| public native | sortNewsortNew() as Array<T> |
Returns a sorted copy without modifying the current array. |
| public native override | toStringtoString() as String |
Returns the fixed-array textual representation. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | operator in(item as T) as Boolean | Returns true when the array contains the given element. |
| public native static | operator!=(readonly notnull left as Array, readonly notnull right as Array) as Boolean | Compares two arrays structurally for inequality. |
| public native static | operator==(readonly notnull left as Array, readonly notnull right as Array) as Boolean | Compares two arrays structurally. |
| public native | operator[](index as Int) as T | Returns or replaces the element at the given index. |