list.ql

util/list.ql
Contents of the file.

Function Overview

Function Description
native fun size() on list Gets the size of the list.
fun isEmpty(lst) on list Checks if the list is empty.
native fun add(item) on list Adds an item to the list.
native fun add(index, item) on list Adds an item to the list at the specified index.
native fun addAll(itemList) on list Adds all items of the given list to the current list.
native fun remove(index) on list Removes an item from the list at the given index.
native fun contains(item) on list Checks if the given item is contained in the list.
native fun subList(fromIndex, toIndex) on list Returns a portion of the current list from the specified starting index to the end of the list.
native fun indexOf(item) on list Checks the index of the given item in the list.
native fun join(delimiter) on list Joins the items of the list into a single string.
native fun sort() on list Sorts a list of numbers or strings in-place.
native fun sortReverse() on list Sorts a list of numbers or strings in-place, in reverse order.

Functions

native fun size() on list link

Gets the size of the list.

Returns int

The number of items in the list

fun isEmpty(lst) on list link

Checks if the list is empty.

Returns boolean

If the list is empty

native fun add(item) on list link

Adds an item to the list.

Params
item

The item to add

native fun add(index, item) on list link

Adds an item to the list at the specified index.

Params
index

The index to add the item at

item

The item to add

Errors

If the index is out of bounds

native fun addAll(itemList) on list link

Adds all items of the given list to the current list.

Params
itemList

The items to add

native fun remove(index) on list link

Removes an item from the list at the given index.

Params
index

The index of the item to remove

Returns

The item that was removed

Errors

If the index is out of bounds

native fun contains(item) on list link

Checks if the given item is contained in the list.

Params
index

The index of the item to remove

Returns boolean

If the specified item is in the list

native fun subList(fromIndex, toIndex) on list link

Returns a portion of the current list from the specified starting index to the end of the list.

Params
fromIndex

The inclusive starting index of the list

toIndex

The exclusive ending index of the list

Returns list

The created sublist

native fun indexOf(item) on list link

Checks the index of the given item in the list.

Params
item

The item to check the location of

Returns int

The index of the item, or -1 if it is not in the list

native fun join(delimiter) on list link

Joins the items of the list into a single string.

Params
delimiter

The string to join the items with

Returns string

The joined string

native fun sort() on list link

Sorts a list of numbers or strings in-place.

Returns list

The sorted list

native fun sortReverse() on list link

Sorts a list of numbers or strings in-place, in reverse order.

Returns list

The sorted list