subList


Description:

public ArrayList<T> subList (int from, int to)

Returns a new ArrayList containing elements from index from (inclusive) to index to (exclusive). If the indices are out of bounds, they are clamped to valid range. If from >= to, returns an empty list.

Example:

    var list = new ArrayList<string> (GLib.str_equal);
list.add ("a");
list.add ("b");
list.add ("c");
var sub = list.subList (0, 2);
assert (sub.size () == 2);
assert (sub.get (0) == "a");
assert (sub.get (1) == "b");

Parameters:

from

the start index (inclusive).

to

the end index (exclusive).

Returns:

a new ArrayList containing the sub-range.