Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


NativeList<T>

An unmanaged, resizable list.
Read time 3 minutesLast updated 7 days ago

Definition

public struct NativeList<T> : INativeDisposable, IDisposable, INativeList<T>, IIndexable<T>, IEnumerable<T>, IEnumerable where T : unmanaged

Remarks

The elements are stored contiguously in a buffer rather than as linked nodes.

Static Fields

Value

Description

MaxCapacityThe maximum number of elements this type of container can hold.

Constructors

Constructor

Description

NativeList`1(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns a NativeList.
NativeList`1(Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns a NativeList with a capacity of one.

Properties

Property

Description

CapacityThe number of elements that fit in the current allocation.
IsCreatedWhether this list has been allocated (and not yet deallocated).
IsEmptyWhether this list is empty.
this[]The element at a given index.
LengthThe count of elements.

Methods

Method

Description

AddAppends an element to the end of this list.
AddNoResizeAppends an element to the end of this list.
AddRangeCopies elements from a ReadOnlySpan to the end of this list.
AddRangeNoResizeCopies elements from a ReadOnlySpan to the end of this list.
AddReplicateAppends value count times to the end of this list.
AsArrayReturns a native array that aliases the content of this list.
AsDeferredJobArrayReturns 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.
AsParallelReaderReturns a parallel reader of this list.
AsParallelWriterReturns a parallel writer of this list.
AsReadOnlyReturns a read only of this list.
AsReadOnlySpanReturns ReadOnlySpan\<T\> view of this container.
AsSpanReturns Span\<T\> view of this container.
ClearSets the length to 0.
CopyFromCopies all elements of specified container to this container.
DisposeReleases all resources (memory and safety handles).
ElementAtReturns a reference to the element at an index.
GetEnumeratorReturns an enumerator over the elements of this list.
GetUnsafeListReturns the internal unsafe list.
GetUnsafePtrGet a pointer to the data.
GetUnsafeReadOnlyPtrGet a pointer to the data.
InsertRangeShifts elements toward the end of this list, increasing its length.
InsertRangeWithBeginEndShifts elements toward the end of this list, increasing its length.
RemoveAtRemoves the element at an index, shifting everything above it down by one. Decrements the length by 1.
RemoveAtSwapBackCopies the last element of this list to the specified index. Decrements the length by 1.
RemoveRangeRemoves "N" elements in a range, shifting everything above the range down by "N". Decrements the length by "N".
RemoveRangeSwapBackCopies the last "N" elements of this list to a range in this list. Decrements the length by "N".
ResizeSets the length of this list, increasing the capacity if necessary.
ResizeUninitializedSets the length of this list, increasing the capacity if necessary.
SetCapacitySets the capacity.
ToArrayReturns an array containing a copy of this list's content.
TrimExcessSets the capacity to match the length.

Structs

Struct

Description

NativeList<T>.ParallelWriterA parallel writer for a NativeList.