Unit core.list

Dernière publication : Aug 10, 2026
Script unit that provides methods to create and update lists.
Methods
procedure add(values: list<ItemType>, element: ItemType) Add an element to values list.
procedure addAll(values: list<ItemType>, elements: list<ItemType>): boolean Add all elements to values list.
function contains(values: list<ItemType>, element: ItemType): boolean Returns true if values list contains an element.
function containsAll(values: list<ItemType>, element: ItemType): boolean Returns true if values list contains all elements.
function indexOf(values: list<ItemType>, element: ItemType) Return the index of the first occurrence of element in values list.
function isEmpty(value: list<ItemType>): boolean Returns true if value is null or a zero size list.
function lastIndexOf(values: list<ItemType>, element: ItemType) Return the index of the last occurrence of element in values list.
function of<ItemType>(value: ItemType [, value: ItemType]...): list<ItemType> Creates a list with the elements passed as parameters.
function remove(values: list<ItemType>, element: ItemType): boolean Remove the first occurrence of an element from values list.
function removeAll(values: list<ItemType>, elements: list<ItemType>): boolean Remove all elements from values list.
function retainAll(values: list<ItemType>, elements: list<ItemType>): boolean Retains only the elements in the values list that are contained in the elements.
procedure reverse(values: list<ItemType>) Reverses the order of elements in values.
procedure reverseSort(values: list<ItemType>) Sorts the specified values list into descending order, according to the natural ordering of its elements.
procedure sort(values: list<ItemType>) Sorts the specified values list into ascending order, according to the natural ordering of its elements.
function subList<ItemType>(values: list<ItemType>, startIndex: decimal, endIndex: decimal): list<ItemType> Returns a new list that contains a subsequence of elements from values list.
Related information
API

add

procedure add(values: list<ItemType>, element: ItemType)
Add an element to values list.
Parameters :
values: the input list.
element: the input element to add. Its type must be compatible with the type of the list.

addAll

procedure addAll(values: list<ItemType>, elements: list<ItemType>): boolean
Add all elements to values list.
Parameters :
values: the input list.
elements: the elements to add. The element type must be compatible with the type of the list.
Return :
true after values list contents was modified by this call else false.

contains

function contains(values: list<ItemType>, element: ItemType): boolean
Returns true if values list contains an element.
Parameters :
values: the input list. Contents must be of the same kind then element.
element: the input element to look for. Must be of the same kind than values contents.
Return :
true if value contains the element else false.
Returns null if values is null.

containsAll

function containsAll(values: list<ItemType>, element: ItemType): boolean
Returns true if values list contains all elements.
Parameters :
values: the input list. Contents must be of the same kind then element.
elements: the input elements to look for. Must be of the same kind than values.
Return :
true if value contains all elements else false.
Returns null if any parameters is null.

indexOf

function indexOf(values: list<ItemType>, element: ItemType)
Return the index of the first occurrence of element in values list.
Parameters :
values: the input list.
element: the input element to look for. Its type must be compatible with the type of the list.
Return :
the index of the first occurrence of element in values list or null if not found.

isEmpty

function isEmpty(value: list<ItemType>): boolean
Returns true if value is null or a zero size list.
Parameters :
values: an input list.
Return :
true if value is null or a zero size list, or else false. Never returns null.

lastIndexOf

function lastIndexOf(values: list<ItemType>, element: ItemType)
Return the index of the last occurrence of element in values list.
Parameters :
values: the input list.
element: the input element to look for.
Return :
the index of the last occurrence of element in values list or null if not found.

of

function of<ItemType>(value: ItemType ...): list<ItemType>
Creates a list with the elements passed as parameters. All elements must be of same type.
Example:
uses core.list as list;

function getCities(): list<string>
begin
  return list.of('Paris', 'Bruxelles', 'Berlin');
end
Function Types :
ItemType: the type of an item of the returned list. Is optional if at least one value is specified.
Parameters :
value: an item to add to the list. All items must be of same type.
Return :
the new list. It is updatable.

remove

function remove(values: list<ItemType>, element: ItemType): boolean
Remove the first occurrence of an element from values list.
Parameters :
values: the input list.
element: the input element to add. Its type must be compatible with the type of the list.
Return :
true if values list contents was modified by this call else false.

removeAll

function removeAll(values: list<ItemType>, elements: list<ItemType>): boolean
Remove all elements from values list.
Parameters :
values: the input list.
elements: the elements to remove. The element type must be compatible with the type of the list.
Return :
true if values list contents was modified by this call else false.

retainAll

function retainAll(values: list<ItemType>, elements: list<ItemType>): boolean
Retains only the elements in the values list that are contained in the elements. In other words, removes from the values list all of its elements that are not contained in the elements.
Parameters :
values: the input list.
elements: the elements to retain. The element type must be compatible with the type of the list.
Return :
true if values list contents was modified by this call else false.

reverse

procedure reverse(values: list<ItemType>)
Reverses the order of elements in values. Does nothing if values is null or a zero size list.
Parameters :
values: the input list to reverse.

reverseSort

procedure reverseSort(values: list<ItemType>)
Sorts the specified values list into descending order, according to the natural ordering of its elements. Does nothing if values is null or a zero size list.
Parameters :
values: the input list to sort.

sort

procedure sort(values: list<ItemType>)
Sorts the specified values list into ascending order, according to the natural ordering of its elements. Does nothing if values is null or a zero size list.
Parameters :
values: the input list to sort

subList

function subList<ItemType>(values: list<ItemType>, startIndex: decimal, endIndex: decimal): list<ItemType>
Returns a new list that contains a subsequence of elements from values list.
The subList start from the specified startIndex and extends to the endIndex of the input list.
Function Types :
ItemType: the type of an item of the returned list. It is optional.
Parameters :
values: the input list
startIndex: the input start index. Must be a positive integer or zero.
endIndex: the input end index. Must be a positive integer or zero.
Return :
the new list or null if any parameter is null.