Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

NativeList<T0>

struct in Unity.Collections


Implements interfaces:IIndexable<T0>, INativeDisposable, INativeList<T0>

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

An unmanaged, resizable list.

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

Static Properties

Property Description
MaxCapacity The maximum number of elements this type of container can hold.

Properties

Property 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.
Length The count of elements.
this[int] The element at a given index.

Constructors

Constructor Description
NativeList_1 Initializes and returns a NativeList with a capacity of one.

Public Methods

Method Description
Add Appends an element to the end of this list.
AddNoResize Appends an element to the end of this list.
AddRange Appends the elements of an array to the end of this list.
AddRangeNoResize Appends elements from a buffer to the end of this list.
AddReplicate 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.
AsReadOnlySpan Returns ReadOnlySpan<T> view of this container.
AsSpan Returns Span<T> view of this container.
Clear Sets the length to 0.
CopyFrom Copies all elements of specified container to this container.
Dispose Releases all resources (memory and safety handles).
ElementAt 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.
GetUnsafePtr Get a pointer to the data.
GetUnsafeReadOnlyPtr Get a pointer to the data.
InsertRange Shifts elements toward the end of this list, increasing its length.
InsertRangeWithBeginEnd Shifts elements toward the end of this list, increasing its length.
RemoveAt Removes the element at an index, shifting everything above it down by one. Decrements the length by 1.
RemoveAtSwapBack Copies the last element of this list to the specified index. Decrements the length by 1.
RemoveRange Removes "N" elements in a range, shifting everything above the range down by "N". Decrements the length by "N".
RemoveRangeSwapBack Copies the last "N" elements of this list to a range in this list. Decrements the length by "N".
Resize Sets the length of this list, increasing the capacity if necessary.
ResizeUninitialized Sets the length of this list, increasing the capacity if necessary.
SetCapacity Sets the capacity.
ToArray Returns an array containing a copy of this list's content.
TrimExcess Sets the capacity to match the length.

Operators

Operator Description
ReadOnlySpan<T> Implicit cast to ReadOnlySpan<T>.
Span<T> Implicit cast to Span<T>.