List$Typings<T> extension

on

Properties

count num
This read-only property is the length of the List.
getter/setter pair
iterator Iterator<T>
Gets an object that you can use for iterating over the List. The key will be an integer from zero to the count-1. The value will be the item at that index in the list. Typical usage:
getter/setter pair
iteratorBackwards Iterator<T>
Gets an object that you can use for iterating over the List in backwards order. The key will be an integer from count-1 to zero. The value will be the item at that index in the list. The list is not modified by traversing in reverse order. Typical usage:
getter/setter pair
length num
This read-only property is the length of the List, a synonym for the #count property.
getter/setter pair
size num
This read-only property is the length of the List.
getter/setter pair

Methods

add(T val) List<T>
Adds a given value to the end of the List.
addAll(Object coll) List<T>
Adds all of the values of a collection to the end of this List.
all(bool pred(T)) bool
This is true if all invocations of the given predicate on items in the collection are true.
any(bool pred(T)) bool
This is true if any invocation of the given predicate on items in the collection is true.
clear() → void
Clears the List. This sets the #count to zero.
contains(T val) bool
Returns whether the given value is in this List. @param {T} val The value to check. @return {boolean} Whether or not the value is contained within the List.
copy() List<T>
Makes a shallow copy of this List. The values are not copied, so if they are objects they may continue to be shared with the original List. @expose @return {List.
delete(T val) bool
Removes a given value (if found) from the List.
each(void func(T)) List<T>
Call the given function on each item in the collection. @expose @param {function(T)} func This function must not modify the collection. @return {List.
elt(num i) → T
Returns the element at the given index. @param {number} i int The index of the element to return. @return {T} the value at the given index.
filter(bool pred(T)) List<T>
Call the given predicate on each item in the collection and for each item that it returns true, collect the item in a new List.
first() → T?
Returns the first item in the list, or null if there is none. @return {T|null} This returns null if there are no items in the list.
get(num i) → T
Returns the element at the given index. @param {number} i int The index of the element to return. @return {T} the value at the given index.
has(T val) bool
Returns whether the given value is in this List. @param {T} val The value to check. @return {boolean} Whether or not the value is contained within the List.
indexOf(T val) num
Returns the index of the given value if it is in this List. @param {T} val The value to check. @return {number} int returns -1 if the value is not in this list.
insertAt(num i, T val) → void
Insert a value before the index i.
last() → T?
Returns the last item in the list, or null if these is none. @return {T|null} This returns null if there are no items in the list. @since 1.5
map<S>(S func(T)) List<S>
Call the given function on each item in the collection and collect the results in a new List.
pop() → T?
Returns the last item in the list and removes it from the list, or just return null if these is none. Use #add to push an item onto the end of the list. Use #last to get the last item without reducing the length of the list. @return {T|null} This returns null if there are no items in the list. @since 1.5
push(T val) → void
Adds a given value to the end of the List.
remove(T val) bool
Removes a given value (if found) from the List.
removeAt(num i) → void
Removes a value at a given index from the List.
removeRange(num from, num to) List<T>
Removes a range of values from the List, given both the starting and the ending zero-based indexes. For example,
reverse() List<T>
Reverse the order of items in this List. @return {List.
set(num i, T val) → void
Set the element at the given index to a given value. @param {number} i int The index of the element to set. @param {T} val The value to set at the index.
setElt(num i, T val) → void
Set the element at the given index to a given value. @param {number} i int The index of the element to set. @param {T} val The value to set at the index.
sort(num sortfunc(T, T)) List<T>
Sort the List according to a comparison function. @param {function(T,T):number} sortfunc This function is passed two items in the list. It should return zero if they are equal, less than zero if the first value should come before the second value, or greater than zero if the first value should come after the second value. @return {List.
sortRange(num sortfunc(T, T), [num? from, num? to]) List<T>
(undocumented) Sorts a range of consecutive elements in this List based on the given comparison function. @param {function(,):number} sortfunc This function is passed two elements in the list. It should return zero if they are equal, less than zero if the first value should come before the second value, or greater than zero if the first value should come after the second value. @param {number=} from int The optional index at which to start the sort, including that element; default to zero, the first element of the list. @param {number=} to int The optional index at which to end the sort, excluding that element; defaults to the end of the list. @return {List.
toArray() Array<T>
Produces a JavaScript Array from the contents of this List. @return {Array.
toSet() Set<T>
Converts the List to a Set. The count of the resulting Set may be less than the count of this List if any duplicates were removed. @return {Set.
toString$() String
@return {string}