Class DynamicArray<T>
Generic growable array.
Namespace: UnityEngine.Rendering
Syntax
public class DynamicArray<T>
where T : new()
Type Parameters
| Name | Description |
|---|---|
| T | Type of the array. |
Constructors
DynamicArray()
Constructor. Defaults to a size of 32 elements.
Declaration
public DynamicArray()
DynamicArray(Int32)
Constructor
Declaration
public DynamicArray(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | Number of elements. |
Properties
capacity
Allocated size of the array.
Declaration
public int capacity { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Item[Int32]
ref access to an element.
Declaration
public T this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | Element index |
Property Value
| Type | Description |
|---|---|
| T | The requested element. |
size
Number of elements in the array.
Declaration
public int size { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Methods
Add(T)
Add an element to the array.
Declaration
public int Add(in T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | Element to add to the array. |
Returns
| Type | Description |
|---|---|
| Int32 | The index of the element. |
Clear()
Clear the array of all elements.
Declaration
public void Clear()
Resize(Int32, Boolean)
Resize the Dynamic Array. This will reallocate memory if necessary and set the current size of the array to the provided size.
Declaration
public void Resize(int newSize, bool keepContent = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | newSize | New size for the array. |
| Boolean | keepContent | Set to true if you want the current content of the array to be kept. |