Public Member Functions | |
void | insertAt (uint index, const T &in value) |
Inserts a new element into the array at the specified index. | |
void | insertAt (uint index, const T[]&inout arr) |
Inserts another array of elements into the array at the specified index. | |
void | insertLast (const T &in value) |
Appends an element at the end of the array. | |
void | removeAt (uint index) |
Removes the element at the specified index. | |
void | removeLast () |
Removes the last element of the array. | |
void | removeRange (uint start, uint count) |
Removes count elements starting from start. | |
uint | length () const |
Returns the length of the array. | |
void | reserve (uint length) |
void | resize (uint length) |
Sets the new length of the array. | |
void | sortAsc () |
Sorts the elements in the array in ascending order. For object types, this will use the type's opCmp method. | |
void | sortAsc (uint startAt, uint count) |
Sorts only the elements starting at index startAt and the following count elements in the array in ascending order. For object types, this will use the type's opCmp method. | |
void | sortDesc () |
Sorts the elements in the array in descending order. For object types, this will use the type's opCmp method. | |
void | sortDesc (uint startAt, uint count) |
Sorts only the elements starting at index startAt and the following count elements in the array in descending order. For object types, this will use the type's opCmp method. | |
void | reverse () |
Reverses the order of the elements in the array. | |
int | find (const T &in value) const |
Returns the index of the first element that has the same value as the wanted value. For object types, this will use the type's opEquals or opCmp method to compare the value. For arrays of handles any null handle will be skipped. If no match is found will return a negative value. | |
int | find (uint startAt, const T &in value) const |
Returns the index of the first element that has the same value as the wanted value. For object types, this will use the type's opEquals or opCmp method to compare the value. For arrays of handles any null handle will be skipped. If no match is found will return a negative value. | |
int | findByRef (const T &in value) const |
Searches for a matching address. These are especially useful for arrays of handles where specific instances of objects are desired, and not just objects that happen to have equal value. If no match is found will return a negative value. | |
int | findByRef (uint startAt, const T &in value) const |
Searches for a matching address. These are especially useful for arrays of handles where specific instances of objects are desired, and not just objects that happen to have equal value. If no match is found will return a negative value. | |
bool | isEmpty () const |
T & | opIndex (uint index) |
const T & | opIndex (uint index) const |
T &[] | opAssign (const T[]&in) |
bool | opEquals (const T[]&in) const |
funcdef bool | less (const ?&in a, const ?&in b) |
sorting function for sort | |
void | sort (less &in, uint startAt=0, uint count=uint(- 1)) |
sorts array using the passed in less function | |
It is possible to declare array variables with the array identifier followed by the type of the elements within angle brackets.
Example:
@code{.cpp} array<int> a, b, c; array<Foo@> d; @endcode
a, b, and c are now arrays of integers, and d is an array of handles to objects of the Foo type.
When declaring arrays it is possible to define the initial size of the array by passing the length as a parameter to the constructor. The elements can also be individually initialized by specifying an initialization list. Example:
@code{.cpp} array<int> a; // A zero-length array of integers array<int> b(3); // An array of integers with 3 elements array<int> c(3, 1); // An array of integers with 3 elements, all set to 1 by default array<int> d = {5,6,7}; // An array of integers with 3 elements with specific values @endcode
Multidimensional arrays are supported as arrays of arrays, for example:
@code{.cpp} array<array<int>> a; // An empty array of arrays of integers array<array<int>> b = {{1,2},{3,4}} // A 2 by 2 array with initialized values array<array<int>> c(10, array<int>(10)); // A 10 by 10 array of integers with uninitialized values @endcode
Each element in the array is accessed with the indexing operator. The indices are zero based, i.e. the range of valid indices are from 0 to length - 1.
@code{.cpp} a[0] = some_value; @endcode
When the array stores handles the elements are assigned using the handle assignment.
@code{.cpp} // Declare an array with initial length 1 array<Foo@> arr(1); @endcode @code{.cpp} // Set the first element to point to a new instance of Foo @arr[0] = Foo(); @endcode
Arrays can also be created and initialized within expressions as anonymous objects.
@code{.cpp} // Call a function that expects an array of integers as input foo(array<int> = {1,2,3,4}); @endcode
Definition at line 540 of file t1_scriptAPI.cpp.
int array< T >::find | ( | const T &in | value | ) | const |
Returns the index of the first element that has the same value as the wanted value. For object types, this will use the type's opEquals or opCmp method to compare the value. For arrays of handles any null handle will be skipped. If no match is found will return a negative value.
int array< T >::find | ( | uint | startAt, |
const T &in | value ) const |
Returns the index of the first element that has the same value as the wanted value. For object types, this will use the type's opEquals or opCmp method to compare the value. For arrays of handles any null handle will be skipped. If no match is found will return a negative value.
int array< T >::findByRef | ( | const T &in | value | ) | const |
Searches for a matching address. These are especially useful for arrays of handles where specific instances of objects are desired, and not just objects that happen to have equal value. If no match is found will return a negative value.
int array< T >::findByRef | ( | uint | startAt, |
const T &in | value ) const |
Searches for a matching address. These are especially useful for arrays of handles where specific instances of objects are desired, and not just objects that happen to have equal value. If no match is found will return a negative value.
void array< T >::insertAt | ( | uint | index, |
const T &in | value ) |
Inserts a new element into the array at the specified index.
void array< T >::insertAt | ( | uint | index, |
const T &[]inout | arr ) |
Inserts another array of elements into the array at the specified index.
void array< T >::insertLast | ( | const T &in | value | ) |
Appends an element at the end of the array.
bool array< T >::isEmpty | ( | ) | const |
uint array< T >::length | ( | ) | const |
Returns the length of the array.
funcdef bool array< T >::less | ( | const ?&in | a, |
const ?&in | b ) |
sorting function for sort
T &[] array< T >::opAssign | ( | const T &[] | in | ) |
bool array< T >::opEquals | ( | const T &[] | in | ) | const |
T & array< T >::opIndex | ( | uint | index | ) |
const T & array< T >::opIndex | ( | uint | index | ) | const |
void array< T >::removeAt | ( | uint | index | ) |
Removes the element at the specified index.
void array< T >::removeLast | ( | ) |
Removes the last element of the array.
void array< T >::removeRange | ( | uint | start, |
uint | count ) |
Removes count elements starting from start.
void array< T >::reserve | ( | uint | length | ) |
void array< T >::resize | ( | uint | length | ) |
Sets the new length of the array.
void array< T >::reverse | ( | ) |
Reverses the order of the elements in the array.
void array< T >::sort | ( | less & | in, |
uint | startAt = 0, | ||
uint | count = uint(- 1) ) |
sorts array using the passed in less function
void array< T >::sortAsc | ( | ) |
Sorts the elements in the array in ascending order. For object types, this will use the type's opCmp method.
void array< T >::sortAsc | ( | uint | startAt, |
uint | count ) |
Sorts only the elements starting at index startAt and the following count elements in the array in ascending order. For object types, this will use the type's opCmp method.
void array< T >::sortDesc | ( | ) |
Sorts the elements in the array in descending order. For object types, this will use the type's opCmp method.
void array< T >::sortDesc | ( | uint | startAt, |
uint | count ) |
Sorts only the elements starting at index startAt and the following count elements in the array in descending order. For object types, this will use the type's opCmp method.