Enfusion Script API
|
Public Member Functions | |
proto native int | Count () |
O(1) complexity. | |
proto native bool | IsEmpty () |
proto native void | Clear () |
Destroys all elements of the array and sets the Count to 0. | |
proto native void | Compact () |
Frees any underlying memory which is not used. | |
proto void | Set (int n, T value) |
Sets n -th element to given value . | |
proto int | Find (T value) |
Tries to find the first occurrence of value in the array. | |
proto bool | Contains (T value) |
Returns whether value is in array or not. | |
proto T | Get (int n) |
proto int | Insert (T value) |
Inserts element at the end of array. | |
proto int | InsertAt (T value, int index) |
Inserts element at certain position and moves all elements behind this position by one. | |
void | InsertAll (notnull array< T > from) |
Inserts all elements from array. | |
proto native void | Remove (int index) |
Removes element from array. | |
proto native void | RemoveOrdered (int index) |
Removes element from array, but retains all elements ordered. | |
proto native void | Resize (int newSize) |
Resizes the array to given size. | |
proto native void | Reserve (int newSize) |
Reserve memory for given number of elements. | |
proto native void | Swap (notnull array< T > other) |
Swaps the contents of this and other arrays. | |
proto native void | Sort (bool reverse=false) |
Sorts elements of array, depends on underlying type. | |
proto native bool | IsIndexValid (int index) |
Returns whether provided element index of array is valid. | |
proto int | Copy (notnull array< T > from) |
Copies contents of from array to this array. | |
proto int | Init (T init[]) |
proto bool | RemoveItem (T value) |
Removes element from array. | |
proto bool | RemoveItemOrdered (T value) |
Removes element from array, but retain all elements ordered. | |
void | Debug () |
Print all elements in array. | |
int | GetRandomIndex () |
Returns a random index of array. | |
T | GetRandomElement () |
Returns a random element of array. | |
void | SwapItems (int item1_index, int item2_index) |
Public Member Functions inherited from Managed | |
proto external ref Managed | Clone () |
Return shallow copy of object, or null if it is not allowed (not public constructor) | |
Destroys all elements of the array and sets the Count to 0.
The underlying memory of the array is not freed.
Frees any underlying memory which is not used.
For example if the array allocated enough memory for 100 items but only 1 is used (Count() is 1) this frees the memory taken by the remaining 99 items.
Returns whether value is in array or not.
Copies contents of from
array to this array.
Print all elements in array.
Tries to find the first occurrence of value
in the array.
value
if found, -1 otherwise. Returns a random index of array.
If Count is 0, returned index is -1.
Example:
Inserts element at the end of array.
value | Element to be inserted. |
Inserts all elements from array.
from | array from which all elements will be added. |
Example:
Inserts element at certain position and moves all elements behind this position by one.
value | Element to be inserted. |
index | Position at which element is inserted. Must be less than Count(). |
Returns whether provided element index of array is valid.
Removes element from array.
The empty position is replaced by last element, so removal is quite fast but does not retain order.
index | Index of element to be removed |
Removes element from array.
The empty position is replaced by last element, so removal is quite fast but does not retain order.
Removes element from array, but retain all elements ordered.
It's slower than RemoveItem().
Removes element from array, but retains all elements ordered.
It's slower than Remove().
index | Index of element to be removed. |
Reserve memory for given number of elements.
This method is used for optimization purposes when the approximate size is known beforehand.
Resizes the array to given size.
If the newSize
is lower than current Count overflowing objects are destroyed. If the newSize
is higher than current Count missing elements are initialized to zero (null).
Sorts elements of array, depends on underlying type.
Swaps the contents of this and other
arrays.
Does not involve copying of the elements.