Arrayclass represents a dynamically resizable array of objects for which any entry can be accessed in constant time.
template <typename type, int32 baseCount = 0> class Array final : public ImmutableArray<type>
||Returns the current size of an array.|
||Sets the current size of an array.|
||Adds an object to the end of an array.|
||Inserts an object into an array.|
||Removes an object from an array.|
||Removes the last object from an array.|
||Removes all objects from an array.|
||Removes all objects from an array and deallocates storage.|
||Finds a specific element in an array.|
||The type of the class that can be stored in the array.|
||The minimum number of array elements for which storage is available inside the |
explicit Array(int32 count = 0);
||The number of array elements for which space is initially reserved in the array's storage.|
Arrayclass represents a homogeneous array of objects whose type is given by the
typetemplate parameter. Upon construction, the initial size of the array is zero, but space is reserved for the number of objects given by the
countparameter. The array is stored contiguously in memory, allowing constant-time random access to its elements.
As elements are added to the array (using the
Array::AppendArrayElementfunction), the storage size is automatically increased to a size somewhat larger than that needed to store the new element. The cost of adding an element is thus amortized linear time.
baseCounttemplate parameter is zero (the default), then storage space for the array elements is always allocated on the heap separately from the
Arrayobject. If the value of
baseCountis greater than zero, then space for that number of array elements is built into the structure of the
Arrayobject so that no separate allocations need to be made until the size of the array exceeds the value of
countparameter can only be specified if the
baseCounttemplate parameter is zero.
Arrayobject can be implicitly converted to a pointer to its first element. This allows the use of the
operator to access individual elements of the array.
It is possible to iterate over the elements of an array using a range-based for loop. This is illustrated by the following code, where
arrayis a variable of type
for (type& element : array)