Struct PagedFreeList<T>
A growable, sparse list whose internal memory is never relocated once allocated
Namespace: Unity.Media.Utilities
Syntax
public struct PagedFreeList<T> : IDisposable, IEquatable<PagedFreeList<T>>, IValidatable where T : struct
Type Parameters
| Name | Description |
|---|---|
| T | The element type of the list |
Remarks
The intended usage is that allocation and writing will only happen from a single thread, while indexing and releasing may happen from any thread
Constructors
PagedFreeList(Int32, Allocator)
Create a new PagedFreeList
Declaration
public PagedFreeList(int pageCapacity, Allocator allocator = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | pageCapacity | The number of elements per allocated page |
| Allocator | allocator | The allocator to be used |
Properties
Capacity
The currently allocated capacity of the list
Declaration
public int Capacity { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Remarks
Can be called from any thread
Item[Int32]
Returns a reference to the item at the specified index
Declaration
public T this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The index of the desired item |
Property Value
| Type | Description |
|---|---|
| T |
Valid
Whether the list is valid
Declaration
public bool Valid { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Implements
Methods
AllocateIndex()
Allocate the next index for use
Declaration
public int AllocateIndex()
Returns
| Type | Description |
|---|---|
| Int32 | The allocated index |
Remarks
Can only be used from a single thread
Dispose()
Dispose the list's allocated storage
Declaration
public void Dispose()
Equals(PagedFreeList<T>)
Whether this is the same list as another instance
Declaration
public bool Equals(PagedFreeList<T> other)
Parameters
| Type | Name | Description |
|---|---|---|
| PagedFreeList<T> | other | The other instance to compare |
Returns
| Type | Description |
|---|---|
| Boolean |
FreeIndex(Int32)
Release the specified index
Declaration
public void FreeIndex(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The index to release |
Remarks
Can be called from any thread
IndexIsValid(Int32)
Query whether a given index is currently allocated for use
Declaration
public bool IndexIsValid(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | The index to query |
Returns
| Type | Description |
|---|---|
| Boolean | True if the index is allocated, otherwise false |
Remarks
Can be called from any thread (although the value of calling this in a concurrent context is limited)