Struct ArrayRental<T>
Represents array obtained from array pool.
Inherited Members
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public struct ArrayRental<T> : IMemoryOwner<T>, IDisposable, IConvertible<Memory<T>>, IConvertible<ArraySegment<T>>, IConvertible<MemoryOwner<T>>
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. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
ArrayRental(ArrayPool<T>, Int32)
Obtains a new array from array pool.
Declaration
public ArrayRental(ArrayPool<T> pool, int minimumLength)
Parameters
Type | Name | Description |
---|---|---|
ArrayPool<T> | pool | Array pool. |
Int32 | minimumLength | The minimum length of the array. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArrayRental(ArrayPool<T>, Int32, Boolean)
Obtains a new array from array pool.
Declaration
public ArrayRental(ArrayPool<T> pool, int minimumLength, bool clearArray)
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(). |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArrayRental(Int32)
Obtains a new array from Shared.
Declaration
public ArrayRental(int minimumLength)
Parameters
Type | Name | Description |
---|---|---|
Int32 | minimumLength | The minimum length of the array. |
ArrayRental(Int32, Boolean)
Obtains a new array from Shared.
Declaration
public ArrayRental(int minimumLength, bool clearArray)
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> |
Owner
Converts this instance to MemoryOwner<T>.
Declaration
public MemoryOwner<T> Owner { get; }
Property Value
Type | Description |
---|---|
MemoryOwner<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 |
---|---|
Span<T> |
Methods
| Improve this Doc View SourceClear()
Sets all elements of the rented array to default value of type T
.
Declaration
public void Clear()
Dispose()
Returns the array back to the pool.
Declaration
public void Dispose()
ToString()
Gets textual representation of the rented memory.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The textual representation of the rented memory. |
Overrides
Operators
| Improve this Doc View SourceImplicit(ArrayRental<T> to MemoryOwner<T>)
Converts rented array to the memory owner.
Declaration
public static implicit operator MemoryOwner<T>(in ArrayRental<T> array)
Parameters
Type | Name | Description |
---|---|---|
ArrayRental<T> | array | The rented array. |
Returns
Type | Description |
---|---|
MemoryOwner<T> | The array owner. |
Explicit Interface Implementations
| Improve this Doc View SourceIConvertible<MemoryOwner<T>>.Convert()
Declaration
MemoryOwner<T> IConvertible<MemoryOwner<T>>.Convert()
Returns
Type | Description |
---|---|
MemoryOwner<T> |
IConvertible<ArraySegment<T>>.Convert()
Declaration
ArraySegment<T> IConvertible<ArraySegment<T>>.Convert()
Returns
Type | Description |
---|---|
ArraySegment<T> |
IConvertible<Memory<T>>.Convert()
Declaration
Memory<T> IConvertible<Memory<T>>.Convert()
Returns
Type | Description |
---|---|
Memory<T> |