An ArrayList with convenience methods for use in templates and scripts, such as getting a random element, a reversed copy, or a truncated sub-list. Also yields cooperatively to the Governor on each iteration of forEach, so a large collection cannot be used to run a long-lived script or template loop past its execution limit.

Extends: ArrayList


Properties

PropertyReturnsDescription
firstTThe first element in the list.
lastTThe last element in the list.
randomTA single element chosen at random from the list.
reverseKademiArrayList<T>A new list containing the same elements as this one, in reverse order. Does not modify this list.

Methods

getFirst()

Returns: T

The first element in the list.

getLast()

Returns: T

The last element in the list.

getRandom()

Returns: T

A single element chosen at random from the list.

getReverse()

Returns: KademiArrayList<T>

A new list containing the same elements as this one, in reverse order. Does not modify this list.

upTo(int n)

Returns: KademiArrayList<T>

Returns a new list containing at most the first n elements of this list.

ParameterDescription
nthe maximum number of leading elements to include

after(int n)

Returns: KademiArrayList<T>

Returns a new list with the first n elements skipped. For example after(2) returns a list without the first 2 elements. The count is 1-indexed, so after(1) skips the first element while after(0) skips none.

ParameterDescription
nthe number of leading elements to skip

truncate(int maxSize)

Returns: KademiArrayList<T>

Returns a new list with a size no greater than the given argument.

ParameterDescription
maxSizethe maximum number of elements in the new list
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.