libperun

Class std.cont.List

Synopsis

public abstract class List< T > extends Container< T >

Represents an ordered list. All elements in a list can be access by their index, and elements can be appended, prepended, inserted, and so on.

Fields

Constructors

Methods

protected abstract T get(int index);

Get the element at the specified index.

Throws
IndexErrorIf index is out of bounds.
protected abstract void set(int index,T value);

Set the element at the specified index to the given value.

Throws
IndexErrorIf index is out of bounds.
public final T opGet(int index);

Get an element at the specified index. Implements the subscript-get operator.

public final T opSet(int index,T value);

Set the element at the specified index. Implements the subscript-set operator.

public void prepend(T value);

Prepend the specified element to the front of the list.

public void append(T value);

Append the specified element to the end of the list.

public abstract void remove(int index);

Remove the element at the specified index. All higher-numbered elements will thus have their indices decremented.

public abstract void insert(int index,T value);

Insert an element at the specified index. That index becomes the index of the new element, and all elements from that index onwards have their indices incremented.

public abstract int size();

Return the size of the list.

public int find(T element);

Looks for an element and returns its index. Returns -1 if not found.

public bool contains(T element);

Returns true if this list contains the specified element.