Collection of data of the same type ordered by an index for each value, with T taking any type. Valid indexes of a collection range from 0 to ‘size()’ – 1. The attempt to access an incorrect index throws an exception.
PUBLIC METHODS
Integer size()
It returns the total quantity of the elements in a collection.
Return |
|
Integer |
Number of elements. |
T get(Integer index)
It goes through the collection and returns a reference to an element in the specified index. The collection and its size are not modified.
Arguments |
|
index |
Integer: position of the desired element. |
void remove(Integer index)
It goes through the collection and removes the element in the specified index. After removing the element, the size of the collection decreases by one.
Arguments |
|
index |
Integer: index you wish to remove. |
T pop()
It removes and returns the last element to the collection. The size of the collection decreases to one and the element removed from the collection is returned.
Return |
|
T |
Element removed from the collection. |
Exceptions |
IndexOutOfBound – Error trying to access an element in a out of bound index. Index value: index, collection size: size. |
Array<T> selected()
It returns one or more elements selected from a collection. The elements might have been selected programmatically either by using the ‘setSelected’ method or, in the case the Array belongs to a layout, by using as List modifier through a tap of the user in the list. If no element is selected, the list that is returned is empty.
Return |
|
Array<T> |
Selected elements from the collection. |
void setSelected(Array<Integer> índices)
It marks as selected one or more elements from the collection.
Arguments |
|
indexes |
Array<T> elements selected from the collection. |
T shift()
It removes and returns the first element of the collection. The size of the collection decreases by one.
Return |
|
T |
First element of the collection. |
void reverse()
It changes the orders of the elements in the list.
void sort()
It compares all the elements of the list and sorts them in ascending order. The elements with invalid value from the list are sorted at the end of the list. If T is not comparable, the order of the collection will be maintained.
void removeAll()
It removes all the elements in the list. The size of the list stays in zero.
Array<T> clone()
It creates a new instance of an array with the same number of elements. Each element is a new reference to true copies of the objects of the original array.
Return |
|
Array<T> |
New instance with content that is identical to the original array. |
Integer indexOf(T element)
It goes through the list and returns the position of the first occurrence of the parameter element.
.
Arguments |
|
element |
T: element to search. Can be ‘null’ |
Return |
|
Integer |
index of the element. |
void add(T element)
It adds the parameter element at the end of the collection. The size of the collection increases by one.
Arguments |
|
element |
T: element to add. Can be ‘null’ |
Exceptions |
TypeMismatchInAddInCollection – Type mismatch adding an element value of different type in a collection. |
void set(Integer index, T element)
It replaces the element of the collection that is in the parameter index by the parameter element. If the index doesn´t exist, it will throw an exception.
Arguments |
|
index |
Integer: replacement index. |
element |
T: replacement element. |
Exceptions |
TypeMismatchInAddInCollection – Type mismatch adding an element value of different type in a collection. |
Integer push(T element)
It inserts a parameter element at the end of the list. The size of the list increases by one.
Arguments |
|
element |
T: element to add. |
Return |
|
Integer |
Number of elements. |
Exceptions |
TypeMismatchInAddInCollection – Type mismatch adding an element value of different type in a collection. |
Integer unshift(T element)
It inserts a parameter element in the first position of the collection. The size of the collection increases by one and the new size returns.
Arguments |
|
element |
T: element to add. |
Return |
|
Integer |
size of the collection. |
Array<T> concat(Array<T> collection)
It creates and returns a new collection containing the elements of the instance, adding at the end the ones of the coleccion
. If the argument collection is not compatible, it throws an exception.
Arguments |
|
element |
T: element to add. |
Return |
|
Array<T> |
new collection. |
Exceptions |
WrongTypeOfArgumentsInCall – Wrong 1st argument type. Required: ‘%@’ in call of method ‘concat’. |