Represents a collection in which every element has a unique non-negative integer index.
A List is a Collection of its elements, and a
Correspondence from indices to elements.
Direct access to a list element by index produces a
value of optional type. The following idiom may be
used instead of upfront bounds-checking, as long as
the list element type is a non-null type:
value char = "hello world"[index];
if (exists char) { /*do something*/ }
else { /*out of bounds*/ }
To iterate the indexes of a List, use the following
idiom:
for (i->char in "hello world".indexed) { ... }
| Attributes | |
| first | Source Code shared actual default Element? first Returns the first element of this List, if any. |
| hash | Source Code shared actual default Integer hash The hash value of the value, which allows the value
to be an element of a hash-based set or key of a
hash-based map. Implementations must respect the
constraint that if |
| iterator | Source Code An iterator for the elements belonging to this container. |
| last | Source Code shared actual default Element? last Returns the last element of this List, if any. |
| lastIndex | Source Code shared formal Integer? lastIndex The index of the last element of the list, or null if the list is empty. See also: size |
| reversed | Source Code Reverse this list, returning a new list. |
| size | Source Code shared actual default Integer size The number of elements in this sequence, always
See also: lastIndex |
| Inherited Attributes |
| Attributes inherited from: Object |
| Attributes inherited from: Cloneable<Clone> |
| Attributes inherited from: Object |
| Attributes inherited from: Container |
| Attributes inherited from: ContainerWithFirstElement<Element,Null> |
| Attributes inherited from: Correspondence<Key,Item> |
| Attributes inherited from: Iterable<Element> |
| Attributes inherited from: Sized |
| Methods | |
| defines | Source Code Determines if the given index refers to an element
of this sequence, that is, if
|
| equals | Source Code Two
|
| findLast | Source Code The last element which satisfies the given
predicate, if any, or |
| item | Source Code Returns the element of this sequence with the given
index, or |
| withLeading | Source Code Returns a new |
| withTrailing | Source Code Returns a new |
| Inherited Methods |
| Methods inherited from: Category |
| Methods inherited from: Correspondence<Key,Item> |
| Methods inherited from: Iterable<Element> |
| Methods inherited from: Ranged<Index,Span> |