UnsafeList<T>
An unmanaged, resizable list.
Read time 3 minutesLast updated 2 days ago
Definition
- Type: Struct
- Namespace: Unity.Collections.LowLevel.Unsafe
- Assembly: UnityEngine.ManagedKernelModule
- Implements: INativeDisposable, IDisposable, INativeList<T>, IIndexable<T>, IEnumerable<T>, IEnumerable
public struct UnsafeList<T> : INativeDisposable, IDisposable, INativeList<T>, IIndexable<T>, IEnumerable<T>, IEnumerable where T : unmanaged
Fields
Value | Description |
|---|---|
| Allocator | The allocator used to create the internal buffer. |
| m_capacity | The number of elements that can fit in the internal buffer. |
| m_length | The number of elements. |
| Ptr | The internal buffer of this list. |
Static Fields
Value | Description |
|---|---|
| MaxCapacity | The maximum number of elements this type of container can hold. |
Constructors
Constructor | Description |
|---|---|
| UnsafeList`1(`0*,System.Int32) | Initializes and returns an instance of UnsafeList. |
| UnsafeList`1(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle,Unity.Collections.NativeArrayOptions) | Initializes and returns an instance of UnsafeList. |
Properties
Property | Description |
|---|---|
| Capacity | The number of elements that can fit in the internal buffer. |
| IsCreated | Whether this list has been allocated (and not yet deallocated). |
| IsEmpty | Whether the list is empty. |
| this[] | The element at an index. |
| Length | The number of elements. |
Methods
Method | Description |
|---|---|
| Add | Adds an element to the end of the list. |
| AddNoResize | Adds an element to the end of this list. |
| AddRange | Copies elements from a ReadOnlySpan to the end of this list. |
| AddRangeNoResize | Copies elements from a ReadOnlySpan to the end of this list. |
| AddReplicate | Appends value count times to the end of this list. |
| AsParallelReader | Obsolete. Use UnsafeList<T>.AsReadOnly instead. |
| 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). |
| ElementAt | Returns a reference to the element at a given index. |
| GetEnumerator | Returns an enumerator over the elements of the 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, expanding the capacity if necessary. |
| SetCapacity | Sets the capacity. |
| TrimExcess | Sets the capacity to match the length. |
Static Methods
Structs
Struct | Description |
|---|---|
| UnsafeList<T>.Enumerator | An enumerator over the elements of a list. |
| UnsafeList<T>.ParallelReader | Obsolete. Use UnsafeList<T>.ReadOnly instead. |
| UnsafeList<T>.ParallelWriter | A parallel writer for an UnsafeList\<T\>. |
| UnsafeList<T>.ReadOnly | A read only for an UnsafeList\<T\>. |