list.eh
Ordered collection of elements. More...
Types
Functions
def List.add(val: Any);
def List.addall(vals: Array);
def List.clear();
def List.copyinto(from: Int, buf: Array, ofs: Int, len: Int);
def List.eq(other: List): Bool;
def List.filter(f: (Any): Bool): List;
def List.filterself(f: (Any): Bool);
def List.get(at: Int): Any;
def List.indexof(val: Any): Int;
def List.insert(at: Int, val: Any);
def List.insertall(at: Int, vals: Array);
def List.len(): Int;
def List.lindexof(val: Any): Int;
def List.map(f: (Any): Any): List;
def List.mapself(f: (Any): Any);
def List.new(): List;
def List.range(from: Int, to: Int): List;
def List.reduce(f: (Any, Any): Any): Any;
def List.remove(at: Int);
def List.reverse(): List;
def List.set(at: Int, val: Any);
def List.sort(f: (Any, Any): Int): List;
def List.sortself(f: (Any, Any): Int);
def List.toarray(): [Any];
def List.tostr(): String;
|
Description
A
List
is an ordered collection of elements (also known as
sequence).
Like in array, elements of list are enumerated by integer index from 0 to
len()-1, however size of list is not fixed and may increase if needed.
Lists support the same syntax as arrays. This header also provides convenient functions
to
sort,
map,
filter and
fold lists.
var list = new List()
list.addall(["tar", "gate"])
list[0] = "s" + list[0]
println(list)
|
Type details
Sequence of elements.
Function details
Creates new empty list.
Returns the number of elements in this list.
Returns element at the specified position of this list.
def List.set(at: Int, val: Any);
|
Replaces the element at the specified position in this list with the given value.
Adds new element to the end of this list.
Length of list increases by one.
def List.addall(vals: Array);
|
Adds all elements from the specified array to the end of this list.
Length of list increases by length of given array.
def List.insert(at: Int, val: Any);
|
Inserts element at the specified position of this list.
Length of list increases by one.
def List.insertall(at: Int, vals: Array);
|
Inserts all elements from given array at the specified position of this list.
Length of list increases by length of given array.
def List.remove(at: Int);
|
Removes element at the specified position of the list decreasing its length by one.
Removes all elements from the list.
Creates new list containing elements in given range of this list.
def List.indexof(val: Any): Int;
|
Returns index of the first occurence of given value in this list.
If list does not contain given value, returns
-1
.
def List.lindexof(val: Any): Int;
|
Returns index of the last occurence of given value in this list.
If list does not contain given value, returns
-1
.
Creates new list containing only elements from this list that match given condition.
def List.filterself(f: (Any): Bool);
|
Filters this list leaving only elements that match given condition.
Creates new list with elements obtained by applying given mapping to elements of this list.
def List.mapself(f: (Any): Any);
|
Transforms elements of this list using given mapping.
Returns value obtained by sequential applying of given mapping to the elements of this list.
If this list has no elements (its size is 0), this function returns
null
. If the list contains
only one value, that value is returned. Otherwise, function
f is applied to the first two elements
of the list. Then
f is applied to the result and the third element and so on.
Creates new list with elements from this list sorted by given criteria.
The function given as argument should return 0 if its arguments are equal, value less
then 0 if its first argument is less then second and value greater then 0 if its first
argument is greater then second.
Sorts elements of this list using given criteria.
The function given as argument should return 0 if its arguments are equal, value less
then 0 if its first argument is less then second and value greater then 0 if its first
argument is greater then second.
def List.reverse(): List;
|
Creates new list with elements from this list in reverse order.
def List.toarray(): [Any];
|
Allocates new array and fills it with elements of this list.
If you need to create an array of the other type then
Any
, use
List.copyinto.
Copies contents of the list into given array.
Method copies
len elements starting from index
from
to the array
buf starting at the array index
ofs.
Returns text representation of this list.
The returned string has the form
"[element1, element2, ...]"
.
Compares the list with another list for equality.
Returns
true
if two lists has the same length and corresponding
elements are equal.