Class ArrayPool<T>
Array pool for reusing arrays to avoid too many allocations.
Inheritance
System.Object
ArrayPool<T>
Namespace: SuperNet.Netcode.Util
Assembly: cs.temp.dll.dll
Syntax
public sealed class ArrayPool<T>
Type Parameters
Name | Description |
---|---|
T | Underlying array type. |
Constructors
ArrayPool(Int32, Int32)
Create a new array pool.
Declaration
public ArrayPool(int count, int maxLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | Number of arrays this pool can hold. |
System.Int32 | maxLength | Maximum length arrays can be saved at. |
Methods
Expand(T[], Int32, Int32, Int32)
Resize an array created by this pool.
Declaration
public T[] Expand(T[] array, int copyLength, int addLength, int expandLength)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Array to resize. |
System.Int32 | copyLength | Number of bytes to copy to the new array. |
System.Int32 | addLength | Number of bytes to add after the copy length. |
System.Int32 | expandLength | Array length multiplier. |
Returns
Type | Description |
---|---|
T[] | A new resized array. |
Rent(Int32)
Extract an array from this pool or allocate a new one.
Declaration
public T[] Rent(int minimumLength)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minimumLength | Minimum length that the returned array has to be. |
Returns
Type | Description |
---|---|
T[] | An unused array. |
Return(T[])
Return an array back to this pool.
Declaration
public void Return(T[] array)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Array to return. |