Struct NativeList<T>
An unmanaged, resizable list.
Namespace: Unity.Collections
Assembly: solution.dll
Syntax
[NativeContainer]
public struct NativeList<T> : INativeDisposable, INativeList<T>, IIndexable<T> where T : unmanaged
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
Remarks
The elements are stored contiguously in a buffer rather than as linked nodes.
Constructors
Name | Description |
---|---|
NativeList(int, AllocatorHandle) | Initializes and returns a NativeList. |
NativeList(AllocatorHandle) | Initializes and returns a NativeList with a capacity of one. |
Properties
Name | Description |
---|---|
Capacity | The number of elements that fit in the current allocation. |
IsCreated | Whether this list has been allocated (and not yet deallocated). |
IsEmpty | Whether this list is empty. |
this[int] | The element at a given index. |
Length | The count of elements. |
Methods
Name | Description |
---|---|
Add(in T) | Appends an element to the end of this list. |
AddNoResize(T) | Appends an element to the end of this list. |
AddRange(void*, int) | Appends the elements of a buffer to the end of this list. |
AddRange(NativeArray<T>) | Appends the elements of an array to the end of this list. |
AddRangeNoResize(void*, int) | Appends elements from a buffer to the end of this list. |
AddRangeNoResize(NativeList<T>) | Appends the elements of another list to the end of this list. |
AddReplicate(in T, int) | Appends value count times to the end of this list. |
AsArray() | Returns a native array that aliases the content of this list. |
AsDeferredJobArray() | Returns an array that aliases this list. The length of the array is updated when the length of this array is updated in a prior job. |
AsParallelReader() | Returns a parallel reader of this list. |
AsParallelWriter() | Returns a parallel writer of this list. |
AsReadOnly() | Returns a read only of this list. |
Clear() | Sets the length to 0. |
CopyFrom(in UnsafeList<T>) | Copies all elements of specified container to this container. |
CopyFrom(in NativeArray<T>) | Copies all elements of specified container to this container. |
CopyFrom(in NativeList<T>) | Copies all elements of specified container to this container. |
Dispose() | Releases all resources (memory and safety handles). |
Dispose(JobHandle) | Creates and schedules a job that releases all resources (memory and safety handles) of this list. |
ElementAt(int) | Returns a reference to the element at an index. |
GetEnumerator() | Returns an enumerator over the elements of this list. |
GetUnsafeList() | Returns the internal unsafe list. |
InsertRange(int, int) | Shifts elements toward the end of this list, increasing its length. |
InsertRangeWithBeginEnd(int, int) | Shifts elements toward the end of this list, increasing its length. |
RemoveAt(int) | Removes the element at an index, shifting everything above it down by one. Decrements the length by 1. |
RemoveAtSwapBack(int) | Copies the last element of this list to the specified index. Decrements the length by 1. |
RemoveRange(int, int) | Removes N elements in a range, shifting everything above the range down by N. Decrements the length by N. |
RemoveRangeSwapBack(int, int) | Copies the last N elements of this list to a range in this list. Decrements the length by N. |
Resize(int, NativeArrayOptions) | Sets the length of this list, increasing the capacity if necessary. |
ResizeUninitialized(int) | Sets the length of this list, increasing the capacity if necessary. |
SetCapacity(int) | Sets the capacity. |
ToArray(AllocatorHandle) | Returns an array containing a copy of this list's content. |
TrimExcess() | Sets the capacity to match the length. |
Operators
Name | Description |
---|---|
implicit operator NativeArray<T>(NativeList<T>) | Obsolete. Use AsArray() method to do explicit cast instead. |