Script unit that provides methods to create and update lists.
Methods |
---|
function of<ItemType>(value: ItemType [, value: ItemType]...): list<ItemType> Creates a list with the elements passed as parameters. |
function isEmpty(value: list<ItemType>): boolean Returns |
function contains(values: list<ItemType>, element: ItemType): boolean Returns |
function containsAll(values: list<ItemType>, element: ItemType): boolean Returns |
procedure add(values: list<ItemType>, element: ItemType) Add an |
function remove(values: list<ItemType>, element: ItemType): boolean Remove the first occurrence of an |
procedure addAll(values: list<ItemType>, elements: list<ItemType>): boolean Add all |
function removeAll(values: list<ItemType>, elements: list<ItemType>): boolean Remove all |
function retainAll(values: list<ItemType>, elements: list<ItemType>): boolean Retains only the elements in the |
function indexOf(values: list<ItemType>, element: ItemType) Return the index of the first occurrence of |
function lastIndexOf(values: list<ItemType>, element: ItemType) Return the index of the last occurrence of |
Returns a new list that contains a subsequence of elements from |
procedure sort(values: list<ItemType>) Sorts the specified |
procedure reverseSort(values: list<ItemType>) Sorts the specified |
procedure reverse(values: list<ItemType>) Reverses the order of elements in |
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.
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.
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.
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.
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.
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
.
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
.
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
.
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
.
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.
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.
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.
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
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.
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.