Struct ArrayRental<T>
Represents array obtained from array pool.
Implements
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public struct ArrayRental<T> : IDisposable
Type Parameters
Name | Description |
---|---|
T | Type of array elements. |
Constructors
| Improve this Doc View SourceArrayRental(T[])
Rents the array.
Declaration
public ArrayRental(T[] array)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to rent. |
ArrayRental(T[], Int32)
Rents the array.
Declaration
public ArrayRental(T[] array, int length)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | The array to rent. |
Int32 | length | The length of the rented segment. |
ArrayRental(ArrayPool<T>, Int32, Boolean)
Obtains a new array from array pool.
Declaration
public ArrayRental(ArrayPool<T> pool, int minimumLength, bool clearArray = false)
Parameters
Type | Name | Description |
---|---|---|
ArrayPool<T> | pool | Array pool. |
Int32 | minimumLength | The minimum length of the array. |
Boolean | clearArray | Indicates whether the contents of the array should be cleared after calling of Dispose(). |
ArrayRental(Int32, Boolean)
Obtains a new array from
Declaration
public ArrayRental(int minimumLength, bool clearArray = false)
Parameters
Type | Name | Description |
---|---|---|
Int32 | minimumLength | The minimum length of the array. |
Boolean | clearArray | Indicates whether the contents of the array should be cleared after calling of Dispose(). |
Properties
| Improve this Doc View SourceIsEmpty
Gets value indicating that this object is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int64]
Gets the array element by its index.
Declaration
public T this[long index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int64 | index | The index of the array element. |
Property Value
Type | Description |
---|---|
T | The managed pointer to the array element. |
Length
Gets length of the rented array.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
Int32 |
Memory
Gets the memory associated with the rented array.
Declaration
public Memory<T> Memory { get; }
Property Value
Type | Description |
---|---|
Memory<T> |
Segment
Gets the rented array.
Declaration
public ArraySegment<T> Segment { get; }
Property Value
Type | Description |
---|---|
ArraySegment<T> |
Span
Gets the span of array elements.
Declaration
public Span<T> Span { get; }
Property Value
Type | Description |
---|---|
DotNext.Span<T> |
Methods
| Improve this Doc View SourceDispose()
Returns the array back to the pool.
Declaration
public void Dispose()
GetPinnableReference()
Obtains managed pointer to the first element of the rented array.
Declaration
public T GetPinnableReference()
Returns
Type | Description |
---|---|
T | The managed pointer to the first element of the rented array. |
Slice(Int32, Int32)
Returns a slice of the rented array.
Declaration
public ArraySegment<T> Slice(int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | offset | The zero-based index of the first element in the array. |
Int32 | count | The number of elements in the range. |
Returns
Type | Description |
---|---|
ArraySegment<T> | The segment of the rented array. |
ToString()
Gets textual representation of the rented memory.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The textual representation of the rented memory. |
Operators
| Improve this Doc View SourceExplicit(ArrayRental<T> to T[])
Obtains rented array.
Declaration
public static explicit operator T[](in ArrayRental<T> rental)
Parameters
Type | Name | Description |
---|---|---|
ArrayRental<T> | rental | Array rental. |
Returns
Type | Description |
---|---|
T[] |
Remarks
This operation is potentially unsafe because the length of the returned array may differs from Length.