Class PooledArrayBufferWriter<T>
Represents memory writer that is backed by the array obtained from the pool.
Inherited Members
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public sealed class PooledArrayBufferWriter<T> : MemoryWriter<T>, IBufferWriter<T>, IConvertible<ReadOnlyMemory<T>>, IReadOnlyList<T>, IReadOnlyCollection<T>, IGrowableBuffer<T>, IDisposable, IConvertible<ArraySegment<T>>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T | The data type that can be written. |
Remarks
This class provides additional methods for access to array segments in contrast to PooledBufferWriter<T>.
Constructors
| Improve this Doc View SourcePooledArrayBufferWriter()
Initializes a new writer with the default initial capacity and Shared as the array pooling mechanism.
Declaration
public PooledArrayBufferWriter()
PooledArrayBufferWriter(ArrayPool<T>)
Initializes a new writer with the default initial capacity.
Declaration
public PooledArrayBufferWriter(ArrayPool<T> pool)
Parameters
Type | Name | Description |
---|---|---|
ArrayPool<T> | pool | The array pool. |
PooledArrayBufferWriter(ArrayPool<T>, Int32)
Initializes a new writer with the specified initial capacity.
Declaration
public PooledArrayBufferWriter(ArrayPool<T> pool, int initialCapacity)
Parameters
Type | Name | Description |
---|---|---|
ArrayPool<T> | pool | The array pool. |
Int32 | initialCapacity | The initial capacity of the writer. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
PooledArrayBufferWriter(Int32)
Initializes a new writer with the specified initial capacity and Shared as the array pooling mechanism.
Declaration
public PooledArrayBufferWriter(int initialCapacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | initialCapacity | The initial capacity of the writer. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Properties
| Improve this Doc View SourceCapacity
Gets the total amount of space within the underlying memory.
Declaration
public override int Capacity { get; }
Property Value
Type | Description |
---|---|
Int32 |
Overrides
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | This writer has been disposed. |
Item[Int32]
Gets the element at the specified index.
Declaration
public T this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The index of the element to retrieve. |
Property Value
Type | Description |
---|---|
T | The element at the specified index. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ObjectDisposedException | This writer has been disposed. |
WrittenArray
Gets the daya written to the underlying array so far.
Declaration
public ArraySegment<T> WrittenArray { get; }
Property Value
Type | Description |
---|---|
ArraySegment<T> |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | This writer has been disposed. |
WrittenMemory
Gets the data written to the underlying buffer so far.
Declaration
public override ReadOnlyMemory<T> WrittenMemory { get; }
Property Value
Type | Description |
---|---|
ReadOnlyMemory<T> |
Overrides
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | This writer has been disposed. |
Methods
| Improve this Doc View SourceClear()
Clears the data written to the underlying buffer.
Declaration
public override void Clear()
Overrides
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | This writer has been disposed. |
Clear(Boolean)
Clears the data written to the underlying memory.
Declaration
public override void Clear(bool reuseBuffer)
Parameters
Type | Name | Description |
---|---|---|
Boolean | reuseBuffer | true to reuse the internal buffer; false to destroy the internal buffer. |
Overrides
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | This writer has been disposed. |
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing |
Overrides
GetArray(Int32)
Returns the memory to write to that is at least the requested size.
Declaration
public ArraySegment<T> GetArray(int sizeHint = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sizeHint | The minimum length of the returned memory. |
Returns
Type | Description |
---|---|
ArraySegment<T> | The memory block of at least the size |
Exceptions
Type | Condition |
---|---|
OutOfMemoryException | The requested buffer size is not available. |
ObjectDisposedException | This writer has been disposed. |
GetMemory(Int32)
Returns the memory to write to that is at least the requested size.
Declaration
public override Memory<T> GetMemory(int sizeHint = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sizeHint | The minimum length of the returned memory. |
Returns
Type | Description |
---|---|
Memory<T> | The memory block of at least the size |
Overrides
Exceptions
Type | Condition |
---|---|
OutOfMemoryException | The requested buffer size is not available. |
ObjectDisposedException | This writer has been disposed. |
GetSpan(Int32)
Returns the memory to write to that is at least the requested size.
Declaration
public override Span<T> GetSpan(int sizeHint = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | sizeHint | The minimum length of the returned memory. |
Returns
Type | Description |
---|---|
Span<T> | The memory block of at least the size |
Overrides
Exceptions
Type | Condition |
---|---|
OutOfMemoryException | The requested buffer size is not available. |
ObjectDisposedException | This writer has been disposed. |
RemoveFirst(Int32)
Removes the specified number of elements from the head of this buffer.
Declaration
public void RemoveFirst(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | The number of elements to be removed from the head of this buffer. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ObjectDisposedException | This writer has been disposed. |
RemoveLast(Int32)
Removes the specified number of elements from the tail of this buffer.
Declaration
public void RemoveLast(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | The number of elements to be removed from the tail of this buffer. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
ObjectDisposedException | This writer has been disposed. |
Explicit Interface Implementations
| Improve this Doc View SourceIConvertible<ArraySegment<T>>.Convert()
Declaration
ArraySegment<T> IConvertible<ArraySegment<T>>.Convert()
Returns
Type | Description |
---|---|
ArraySegment<T> |
ICollection<T>.Contains(T)
Declaration
bool ICollection<T>.Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
Boolean |
ICollection<T>.CopyTo(T[], Int32)
Declaration
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | |
Int32 | arrayIndex |
ICollection<T>.Count
Declaration
int ICollection<T>.Count { get; }
Returns
Type | Description |
---|---|
Int32 |
ICollection<T>.IsReadOnly
Declaration
bool ICollection<T>.IsReadOnly { get; }
Returns
Type | Description |
---|---|
Boolean |
ICollection<T>.Remove(T)
Declaration
bool ICollection<T>.Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
Boolean |
IList<T>.IndexOf(T)
Declaration
int IList<T>.IndexOf(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
Int32 |
IList<T>.Insert(Int32, T)
Declaration
void IList<T>.Insert(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | |
T | item |
IList<T>.Item[Int32]
Declaration
T IList<T>.this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
Returns
Type | Description |
---|---|
T |
IList<T>.RemoveAt(Int32)
Declaration
void IList<T>.RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |