# UnsafePtrList<T>

> An unmanaged, resizable list of pointers.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections.LowLevel.Unsafe](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeDisposable](/engine/6000.7/script-reference/unity/collections/inativedisposable.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable), [IEnumerable\<IntPtr>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

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

## Fields

| Value                                                                                                         | Description                                                 |
| ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| [Allocator](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/allocator.md)    | The allocator used to create the internal buffer.           |
| [m\_capacity](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/m-capacity.md) | The number of elements that can fit in the internal buffer. |
| [m\_length](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/m-length.md)     | The number of elements.                                     |
| [Ptr](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/ptr.md)                | The internal buffer of this list.                           |

## Constructors

| Constructor                                                                                                                                                                                                                                                                | Description                                           |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| [UnsafePtrList\`1(\`0\*\*,System.Int32)](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/ctor.md#unsafeptrlist\(0**-int\))                                                                                                                | Initializes and returns an instance of UnsafePtrList. |
| [UnsafePtrList\`1(System.Int32,Unity.Collections.AllocatorManager.AllocatorHandle,Unity.Collections.NativeArrayOptions)](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/ctor.md#unsafeptrlist\(int-allocatorhandle-nativearrayoptions\)) | Initializes and returns an instance of UnsafePtrList. |

## Properties

| Property                                                                                                   | Description                                                     |
| ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [Capacity](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/capacity.md)   | The number of elements that can fit in the internal buffer.     |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/iscreated.md) | Whether this list has been allocated (and not yet deallocated). |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/isempty.md)     | Whether the list is empty.                                      |
| [this\[\]](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/item.md)       | The element at an index.                                        |
| [Length](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/length.md)       | The number of elements.                                         |

## Methods

| Method                                                                                                                                 | Description                                                                                                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Add](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/add.md)                                         | Adds a pointer to the end of the list.                                                                                                                    |
| [AddNoResize](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/addnoresize.md)                         | Adds a pointer to the end of this list.                                                                                                                   |
| [AddRange](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/addrange.md)                               | Adds elements from a buffer to this list.                                                                                                                 |
| [AddRangeNoResize](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/addrangenoresize.md)               | Copies pointers from a buffer to the end of this list.                                                                                                    |
| [AsParallelReader](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/asparallelreader.md)               | **Obsolete**. Use [UnsafePtrList\<T>.AsReadOnly](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/asreadonly.md) instead. |
| [AsParallelWriter](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/asparallelwriter.md)               | Returns a parallel writer of this list.                                                                                                                   |
| [AsReadOnly](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/asreadonly.md)                           | Returns a read only of this list.                                                                                                                         |
| [Clear](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/clear.md)                                     | Sets the length to 0.                                                                                                                                     |
| [Contains](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/contains.md)                               | Returns true if the list contains at least one occurrence of a specific pointer.                                                                          |
| [Dispose](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/dispose.md)                                 | Releases all resources (memory).                                                                                                                          |
| [ElementAt](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/elementat.md)                             | Returns a reference to the element at a given index.                                                                                                      |
| [IndexOf](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/indexof.md)                                 | Returns the index of the first occurrence of a specific pointer in the list.                                                                              |
| [InsertRangeWithBeginEnd](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/insertrangewithbeginend.md) | Shifts pointers toward the end of this list, increasing its length.                                                                                       |
| [RemoveAt](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/removeat.md)                               | Removes the pointer at an index, shifting everything above it down by one. Decrements the length by 1.                                                    |
| [RemoveAtSwapBack](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/removeatswapback.md)               | Copies the last pointer of this list to the specified index. Decrements the length by 1.                                                                  |
| [RemoveRange](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/removerange.md)                         | Removes "N" pointers in a range, shifting everything above the range down by "N". Decrements the length by "N".                                           |
| [RemoveRangeSwapBack](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/removerangeswapback.md)         | Copies the last "N" pointer of this list to a range in this list. Decrements the length by "N".                                                           |
| [Resize](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/resize.md)                                   | Sets the length, expanding the capacity if necessary.                                                                                                     |
| [SetCapacity](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/setcapacity.md)                         | Sets the capacity.                                                                                                                                        |
| [TrimExcess](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/trimexcess.md)                           | Sets the capacity to match the length.                                                                                                                    |

## Static Methods

| Method                                                                                                 | Description                     |
| ------------------------------------------------------------------------------------------------------ | ------------------------------- |
| [Create](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/create.md)   | Returns a new list of pointers. |
| [Destroy](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/destroy.md) | Destroys the list.              |

## Structs

| Struct                                                                                                                                 | Description                                                                                                                                           |
| -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| [UnsafePtrList\<T>.ParallelReader](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/parallelreader.md) | **Obsolete.** Use [UnsafePtrList\<T>.ReadOnly](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/readonly.md) instead. |
| [UnsafePtrList\<T>.ParallelWriter](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/parallelwriter.md) | A parallel writer for an UnsafePtrList\\\<T\\>.                                                                                                       |
| [UnsafePtrList\<T>.ReadOnly](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafeptrlist1/readonly.md)             | A read only for an UnsafePtrList\\\<T\\>.                                                                                                             |
