Array

type
class
An Array is a storage for values. You can access it using indexes or with its API. On the server side, it's often better to use a List which is less memory and CPU consuming, unless you really need indexed access.

Constructor

new()
Creates a new Array.

Instance Variables

length(default,null) : Int

The length of the Array

Instance Methods

concat(a : Array<T>) : Array<T>

Returns a new Array by appending a to this.

copy() : Array<T>

Returns a copy of the Array. The values are not copied, only the Array structure.

insert(pos : Int, x : T) : Void

Inserts the element x at the position pos. All elements after pos are moved one index ahead.

iterator() : Iterator<Null<T>>

Returns an iterator of the Array values.

join(sep : String) : String

Returns a representation of an array with sep for separating each element.

pop() : Null<T>

Removes the last element of the array and returns it.

push(x : T) : Int

Adds the element x at the end of the array.

remove(x : T) : Bool

Removes the first occurence of x. Returns false if x was not present. Elements are compared by using standard equality.

reverse() : Void

Reverse the order of elements of the Array.

shift() : Null<T>

Removes the first element and returns it.

slice(pos : Int, ?end : Int) : Array<T>

Copies the range of the array starting at pos up to, but not including, end. Both pos and end can be negative to count from the end: -1 is the last item in the array.

sort(f : T -> T -> Int) : Void

Sort the Array according to the comparison function f. f(x,y) should return 0 if x == y, >0 if x > y and <0 if x < y.

splice(pos : Int, len : Int) : Array<T>

Removes len elements starting from pos an returns them.

toString() : String

Returns a displayable representation of the Array content.

unshift(x : T) : Void

Adds the element x at the start of the array.