MPS 2019.2 Help

List

A basic list container backed by either array list or linked list.

List type

list<Type>

Subtypes

Supertypes

Comparable types

none

sequence<Type>

java.util.List<Type>

List creation

new arraylist
new linkedlist

Parameter type

Result type

Type...
{*}sequence<? extends *Type>

list<Type>

Creates an empty list. Optionally, initial values may be specified right in the new list creation expression.

e> = new arraylist<Type> { /* initial values */ };


Alternatively, a sequence may be specified that is used to copy elements from.

e> = new arraylist<Type> (sequence);

Operations on list

iterator

Operand type

Parameter type

Result type

sequence<Type>

none

modifying_iterator<Type>

This operation is redefined for list to return a modifying_iterator .

get

Operand type

Parameter type

Result type

list<Type>

int

Type

Yields the element at index position.

(index);
  • indexed access
    ex];

    set

    Operand type

    Parameter type

    Result type

    list<Type>

    int
    Type

    Type

    Sets the element at index position to the specified value. Yields the new value.
    (index, value);
  • indexed access
    ex] = value;

    add

    Operand type

    Parameter type

    Result type

    list<Type>

    Type

    Type

    Adds an element to the list.
    (value);

    addFirst

    Operand type

    Parameter type

    Result type

    list<Type>

    Type

    Type

    Adds an element to the list as the first element.
    First (value);

    addLast

    Operand type

    Parameter type

    Result type

    list<Type>

    Type

    Type

    Adds an element to the list as the last element.
    Last (value);

    insert

    Operand type

    Parameter type

    Result type

    list<Type>

    int
    Type

    Type

    Inserts an element into the list at the position index.
    ert (index, value);

    remove

    Operand type

    Parameter type

    Result type

    list<Type>

    Type

    Type

    Removes an element from the list.
    ove (value);

    removeFirst

    Operand type

    Parameter type

    Result type

    list<Type>

    none

    Type

    Removes the first element from the list.
    oveFirst;

    removeLast

    Operand type

    Parameter type

    Result type

    list<Type>

    none

    Type

    Removes the last element from the list.
    oveLast;

    removeAt

    Operand type

    Parameter type

    Result type

    list<Type>

    int

    Type

    Removes an element from the list located at the position index.
    oveAt (index);

    addAll

    Operand type

    Parameter type

    Result type

    list<Type>

    sequence<Type>

    list<Type>

    Adds all elements in the parameter sequence to the list.
    All (seq);

    removeAll

    Operand type

    Parameter type

    Result type

    list<Type>

    sequence<Type>

    list<Type>

    Removes all elements in the parameter sequence from the list.
    oveAll (seq);

    clear

    Operand type

    Parameter type

    Result type

    list<Type>

    none

    void

    Clears all elements from the list.
    ar;

reverse

Operand type

Parameter type

Result type

list<Type>

none

list<Type>

Produces a list with all elements from the original list in the reversed order.

erse;
Last modified: 30 August 2019