Array

class Array<T>Available in flash, flash9, neko, js, php, cppAn 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. var length(default,null) : IntThe length of the Array. (Read Only) function new() : VoidAvailable in flash, flash9, js, php, cppCreates a new Array. function new() : VoidAvailable in nekoCreates a new Array. function concat( a : Array<T> ) : Array<T>Returns a new Array by appending a to this. function copy() : Array<T>Returns a copy of the Array. The values are not copied, only the Array structure. function insert( pos : Int, x : T ) : VoidInserts the element x at the position pos. All elements after pos are moved one index ahead. If "pos" is bigger than the array length element "x" will be inserted as the last element. function iterator() : Iterator<Null<T>>Returns an iterator of the Array values. function join( sep : String ) : StringReturns a representation of an array with sep for separating each element. function pop() : Null<T>Removes the last element of the array and returns it. function push( x : T ) : IntAdds the element x at the end of the array. Returns the new length of the array. function remove( x : T ) : BoolRemoves the first occurence of x. Returns false if x was not present. Elements are compared by using standard equality. function reverse() : VoidReverse the order of elements of the Array. function shift() : Null<T>Removes the first element and returns it. function 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.
function 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 should appear after y
  • <0 if x should appear before y

function splice( pos : Int, len : Int ) : Array<T>Removes len elements starting from pos an returns them. function toString() : StringReturns a displayable representation of the Array content. function unshift( x : T ) : VoidAdds the element x at the start of the array.
version #12145, modified 2012-01-06 19:25:41 by robertbak