Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


UnsafePtrList<T>

An unmanaged, resizable list of pointers.
Read time 2 minutesLast updated 13 days ago

Definition

public struct UnsafePtrList<T> : INativeDisposable, IDisposable, IEnumerable<nint>, IEnumerable where T : unmanaged

Fields

Value

Description

AllocatorThe allocator used to create the internal buffer.
m_capacityThe number of elements that can fit in the internal buffer.
m_lengthThe number of elements.
PtrThe internal buffer of this list.

Constructors

Constructor

Description

UnsafePtrList`1(`0**,System.Int32)Initializes and returns an instance of UnsafePtrList.
UnsafePtrList`1(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle,Unity.Collections.NativeArrayOptions)Initializes and returns an instance of UnsafePtrList.

Properties

Property

Description

CapacityThe number of elements that can fit in the internal buffer.
IsCreatedWhether this list has been allocated (and not yet deallocated).
IsEmptyWhether the list is empty.
this[]The element at an index.
LengthThe number of elements.

Methods

Method

Description

AddAdds a pointer to the end of the list.
AddNoResizeAdds a pointer to the end of this list.
AddRangeAdds elements from a buffer to this list.
AddRangeNoResizeCopies pointers from a buffer to the end of this list.
AsParallelReaderObsolete. Use UnsafePtrList<T>.AsReadOnly instead.
AsParallelWriterReturns a parallel writer of this list.
AsReadOnlyReturns a read only of this list.
ClearSets the length to 0.
ContainsReturns true if the list contains at least one occurrence of a specific pointer.
DisposeReleases all resources (memory).
ElementAtReturns a reference to the element at a given index.
IndexOfReturns the index of the first occurrence of a specific pointer in the list.
InsertRangeWithBeginEndShifts pointers toward the end of this list, increasing its length.
RemoveAtRemoves the pointer at an index, shifting everything above it down by one. Decrements the length by 1.
RemoveAtSwapBackCopies the last pointer of this list to the specified index. Decrements the length by 1.
RemoveRangeRemoves "N" pointers in a range, shifting everything above the range down by "N". Decrements the length by "N".
RemoveRangeSwapBackCopies the last "N" pointer of this list to a range in this list. Decrements the length by "N".
ResizeSets the length, expanding the capacity if necessary.
SetCapacitySets the capacity.
TrimExcessSets the capacity to match the length.

Static Methods

Method

Description

CreateReturns a new list of pointers.
DestroyDestroys the list.

Structs

Struct

Description

UnsafePtrList<T>.ParallelReaderObsolete. Use UnsafePtrList<T>.ReadOnly instead.
UnsafePtrList<T>.ParallelWriterA parallel writer for an UnsafePtrList\<T\>.
UnsafePtrList<T>.ReadOnlyA read only for an UnsafePtrList\<T\>.