Array
class in package klyn.collections

    public class Array<T> extends Object implements IList<T>:

Object
└ Array
All Implemented Interfaces: IList

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

Properties

Modifier and Type | Member | Description
--- | --- | ---
public readonly native property | size `size as ULong` | Returns the number of elements in the array.

Properties inherited from Object: type
Properties inherited from IList: size
Constructors

Modifier and Type | Member | Description
--- | --- | ---
public native | Array `Array(size as Int)` | Creates a new array with a fixed number of elements.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public native | count `count(item as T) as ULong` | Counts occurrences of the given element.
public native | join `join(separator as String) as String` | Joins array elements into a single string.
public native | reverse `reverse() as Void` | Reverses array elements in-place.
public native | reverseNew `reverseNew() as Array<T>` | Returns a reversed copy without modifying the current array.
public native | sort `sort() as Void` | Sorts array elements in-place.
public native | sortNew `sortNew() as Array<T>` | Returns a sorted copy without modifying the current array.
public native override | toString `toString() as String` | Returns the fixed-array textual representation.

Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Methods inherited from IList: count, join
Operators

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.

Operators inherited from IList: operator in(item as T) as Boolean, operator[](index as Int) as T