Struct ListBuffer<T>
A list that stores value on a provided memory buffer.
Usually use this to have a list on stack allocated memory.
Namespace: UnityEngine.Rendering
Syntax
public struct ListBuffer<T>
where T : struct
Type Parameters
Name | Description |
---|---|
T | The type of the data stored in the list. |
Constructors
ListBuffer(T*, Int32*, Int32)
Instantiate a new list.
Declaration
public ListBuffer(T*bufferPtr, int *countPtr, int capacity)
Parameters
Type | Name | Description |
---|---|---|
T* | bufferPtr | The address in memory to store the data. |
Int32* | countPtr | The address in memory to store the number of item of this list.. |
Int32 | capacity | The number of |
Properties
Capacity
The maximum number of item stored in this list.
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
Int32 |
Count
The number of item in the list.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
Item[Int32]
Get an item from the list.
Declaration
public T this[in int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the item to get. |
Property Value
Type | Description |
---|---|
T | A reference to the item. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | If the index is invalid. |
Methods
CopyTo(T*, Int32, Int32)
Copy the content of this list into another buffer in memory.
Safety:
- The destination must have enough memory to receive the copied data.
Declaration
public void CopyTo(T*dstBuffer, int startDstIndex, int copyCount)
Parameters
Type | Name | Description |
---|---|---|
T* | dstBuffer | The destination buffer of the copy operation. |
Int32 | startDstIndex | The index of the first element that will be copied in the destination buffer. |
Int32 | copyCount | The number of item to copy. |
GetUnchecked(Int32)
Get an item from the list.
Safety: index must be inside the bounds of the list.
Declaration
public T GetUnchecked(in int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the item to get. |
Returns
Type | Description |
---|---|
T | A reference to the item. |
TryAdd(T)
Try to add a value in the list.
Declaration
public bool TryAdd(in T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | A reference to the value to add. |
Returns
Type | Description |
---|---|
Boolean | when the value was added,
when the value was not added because the capacity was reached.
|
TryCopyFrom(T*, Int32)
Try to copy the data from a buffer in this list.
Declaration
public bool TryCopyFrom(T*srcPtr, int count)
Parameters
Type | Name | Description |
---|---|---|
T* | srcPtr | The pointer of the source memory to copy. |
Int32 | count | The number of item to copy from the source buffer. |
Returns
Type | Description |
---|---|
Boolean |
|
TryCopyTo(ListBuffer<T>)
Try to copy the list into another list.
Declaration
public bool TryCopyTo(ListBuffer<T> other)
Parameters
Type | Name | Description |
---|---|---|
ListBuffer<T> | other | The destination of the copy. |
Returns
Type | Description |
---|---|
Boolean |
|