Unit core.list
Script unit that provides methods to create and update lists.
Related information
function of(value: ItemType ...): list
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.
function isEmpty(value: list): 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.
function contains(values: list, 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.
function containsAll(values: list, 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.
procedure add(values: list, 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.
function remove(values: list, 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.
procedure addAll(values: list, elements: list): 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.
function removeAll(values: list, elements: list): 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.
function retainAll(values: list, elements: list): 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.
function indexOf(values: list, 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.
function lastIndexOf(values: list, 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.
function subList(values: list, startIndex: decimal, endIndex: decimal): list
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.
procedure sort(values: list)
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
procedure reverseSort(values: list)
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.
procedure reverse(values: list)
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.