ArrayList


Object Hierarchy:

Object hierarchy for ArrayList

Description:

public class ArrayList<T> : Object

A dynamic array-backed list that grows automatically as elements are added.

ArrayList provides O(1) indexed access and amortized O(1) append. Inspired by Java's ArrayList, Go's slice, and Python's list.

For element comparison in methods like contains() and indexOf(), pass an equality function to the constructor. For string lists, use GLib.str_equal.

Example:

    var list = new ArrayList<string> (GLib.str_equal);
list.add ("hello");
list.add ("world");
assert (list.size () == 2);
assert (list.get (0) == "hello");
assert (list.contains ("hello"));

var filtered = list.filter ((s) => { return s == "hello"; });
assert (filtered.size () == 1);


Namespace: Vala.Collections
Package: Valacore

Content:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class GLib.Object