# UnsafeQueue<T>

> An unmanaged queue.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule
* **Implements:** [INativeDisposable](/engine/6000.7/script-reference/unity/collections/inativedisposable.md), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public struct UnsafeQueue<T> : INativeDisposable, IDisposable where T : unmanaged
```

## Constructors

| Constructor                                                                                                                                  | Description                                         |
| -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| [UnsafeQueue\`1(Unity.Collections.AllocatorManager.AllocatorHandle)](/engine/6000.7/script-reference/unity/collections/unsafequeue1/ctor.md) | Initializes and returns an instance of UnsafeQueue. |

## Properties

| Property                                                                                 | Description                                                      |
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [Count](/engine/6000.7/script-reference/unity/collections/unsafequeue1/count.md)         | Returns the current number of elements in this queue.            |
| [IsCreated](/engine/6000.7/script-reference/unity/collections/unsafequeue1/iscreated.md) | Whether this queue has been allocated (and not yet deallocated). |

## Methods

| Method                                                                                                 | Description                                                         |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
| [AsParallelWriter](/engine/6000.7/script-reference/unity/collections/unsafequeue1/asparallelwriter.md) | Returns a parallel writer for this queue.                           |
| [AsReadOnly](/engine/6000.7/script-reference/unity/collections/unsafequeue1/asreadonly.md)             | Returns a readonly version of this UnsafeQueue instance.            |
| [Clear](/engine/6000.7/script-reference/unity/collections/unsafequeue1/clear.md)                       | Removes all elements of this queue.                                 |
| [Dequeue](/engine/6000.7/script-reference/unity/collections/unsafequeue1/dequeue.md)                   | Removes and returns the element at the front of this queue.         |
| [Dispose](/engine/6000.7/script-reference/unity/collections/unsafequeue1/dispose.md)                   | Releases all resources (memory and safety handles).                 |
| [Enqueue](/engine/6000.7/script-reference/unity/collections/unsafequeue1/enqueue.md)                   | Adds an element at the back of this queue.                          |
| [IsEmpty](/engine/6000.7/script-reference/unity/collections/unsafequeue1/isempty.md)                   | Returns true if this queue is empty.                                |
| [Peek](/engine/6000.7/script-reference/unity/collections/unsafequeue1/peek.md)                         | Returns the element at the front of this queue without removing it. |
| [ToArray](/engine/6000.7/script-reference/unity/collections/unsafequeue1/toarray.md)                   | Returns an array containing a copy of this queue's content.         |
| [TryDequeue](/engine/6000.7/script-reference/unity/collections/unsafequeue1/trydequeue.md)             | Removes and outputs the element at the front of this queue.         |

## Structs

| Struct                                                                                                             | Description                                                                                |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| [UnsafeQueue\<T>.Enumerator](/engine/6000.7/script-reference/unity/collections/unsafequeue1/enumerator.md)         | An enumerator over the values of a container.                                              |
| [UnsafeQueue\<T>.ParallelWriter](/engine/6000.7/script-reference/unity/collections/unsafequeue1/parallelwriter.md) | A parallel writer for a UnsafeQueue.                                                       |
| [UnsafeQueue\<T>.ReadOnly](/engine/6000.7/script-reference/unity/collections/unsafequeue1/readonly.md)             | A read-only alias for the value of a UnsafeQueue. Does not have its own allocated storage. |
