class List<T>

Available on all platforms

A linked-list of elements. The list is composed of two-elements arrays that are chained together. It is optimized so that adding or removing an element does not imply copying the whole array content every time.

Instance Fields

var length:Int

The length of this List.

function new():Void

Creates a new empty list.

function add(item:T):Void

Adds element item at the end of this List.


`this.length` increases by 1.

function clear():Void

Empties this List.


This function does not traverse the elements, but simply sets the
internal references to null and `this.length` to 0.

function filter(f:T ->Bool):List<T>

Returns a list filtered with f. The returned list will contain all

elements for which `f(x) == true`.

function first():Null<T>

Returns the first element of this List, or null if no elements exist.


This function does not modify `this` List.

function isEmpty():Bool

Tells if this List is empty.

function iterator():Iterator<T>

Returns an iterator on the elements of the list.

function join(sep:String):String

Returns a string representation of this List, with sep separating

each element.

function last():Null<T>

Returns the last element of this List, or null if no elements exist.


This function does not modify `this` List.

function map<X>(f:T ->X):List<X>

Returns a new list where all elements have been converted by the

function `f`.

function pop():Null<T>

Returns the first element of this List, or null if no elements exist.


The element is removed from `this` List.

function push(item:T):Void

Adds element item at the beginning of this List.


`this.length` increases by 1.

function remove(v:T):Bool

Removes the first occurence of v in this List.


If `v` is found by checking standard equality, it is removed from `this`
List and the function returns true.

Otherwise, false is returned.

function toString():String

Returns a string representation of this List.


The result is enclosed in { } with the individual elements being
separated by a comma.