Show / Hide Table of Contents

Class PooledArrayBufferWriter<T>

Represents memory writer that is backed by the array obtained from the pool.

Inheritance
Object
Disposable
MemoryWriter<T>
PooledArrayBufferWriter<T>
Implements
IBufferWriter<T>
IConvertible<ReadOnlyMemory<T>>
IReadOnlyList<T>
IReadOnlyCollection<T>
IGrowableBuffer<T>
IDisposable
IConvertible<ArraySegment<T>>
IList<T>
ICollection<T>
IEnumerable<T>
IEnumerable
Inherited Members
MemoryWriter<T>.AllocationCounter
MemoryWriter<T>.BufferSizeCallback
MemoryWriter<T>.IConvertible<ReadOnlyMemory<T>>.Convert()
MemoryWriter<T>.WrittenCount
MemoryWriter<T>.IGrowableBuffer<T>.WrittenCount
MemoryWriter<T>.IGrowableBuffer<T>.Write(ReadOnlySpan<T>)
MemoryWriter<T>.IGrowableBuffer<T>.CopyTo<TArg>(ReadOnlySpanAction<T, TState>, TState)
MemoryWriter<T>.IGrowableBuffer<T>.CopyTo(Span<T>)
MemoryWriter<T>.Add(T)
MemoryWriter<T>.AddAll(ICollection<T>)
MemoryWriter<T>.IReadOnlyCollection<T>.Count
MemoryWriter<T>.IReadOnlyList<T>.Item[Int32]
MemoryWriter<T>.FreeCapacity
MemoryWriter<T>.Advance(Int32)
MemoryWriter<T>.GetEnumerator()
MemoryWriter<T>.IEnumerable.GetEnumerator()
Disposable.IsDisposed
Disposable.ThrowIfDisposed()
Disposable.DisposedTask
Disposable.GetDisposedTask<T>()
Disposable.TrySetDisposedException<T>(TaskCompletionSource<T>)
Disposable.Dispose()
Disposable.QueueDispose(IDisposable)
Disposable.Dispose(IEnumerable<IDisposable>)
Disposable.DisposeAsync(IEnumerable<IAsyncDisposable>)
Disposable.Dispose(IDisposable[])
Disposable.DisposeAsync(IAsyncDisposable[])
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
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 Source

PooledArrayBufferWriter()

Initializes a new writer with the default initial capacity and Shared as the array pooling mechanism.

Declaration
public PooledArrayBufferWriter()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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

initialCapacity is less than or equal to zero.

| Improve this Doc View Source

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

initialCapacity is less than or equal to zero.

Properties

| Improve this Doc View Source

Capacity

Gets the total amount of space within the underlying memory.

Declaration
public override int Capacity { get; }
Property Value
Type Description
Int32
Overrides
DotNext.Buffers.MemoryWriter<T>.Capacity
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

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

index the index is invalid.

ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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
DotNext.Buffers.MemoryWriter<T>.WrittenMemory
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

Methods

| Improve this Doc View Source

Clear()

Clears the data written to the underlying buffer.

Declaration
public override void Clear()
Overrides
DotNext.Buffers.MemoryWriter<T>.Clear()
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

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
DotNext.Buffers.MemoryWriter<T>.Clear(System.Boolean)
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

Dispose(Boolean)

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing
Overrides
DotNext.Buffers.MemoryWriter<T>.Dispose(System.Boolean)
| Improve this Doc View Source

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 sizeHint.

Exceptions
Type Condition
OutOfMemoryException

The requested buffer size is not available.

ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

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 sizeHint.

Overrides
DotNext.Buffers.MemoryWriter<T>.GetMemory(System.Int32)
Exceptions
Type Condition
OutOfMemoryException

The requested buffer size is not available.

ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

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 sizeHint.

Overrides
DotNext.Buffers.MemoryWriter<T>.GetSpan(System.Int32)
Exceptions
Type Condition
OutOfMemoryException

The requested buffer size is not available.

ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

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

count is less than 0.

ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

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

count is less than 0.

ObjectDisposedException

This writer has been disposed.

Explicit Interface Implementations

| Improve this Doc View Source

IConvertible<ArraySegment<T>>.Convert()

Declaration
ArraySegment<T> IConvertible<ArraySegment<T>>.Convert()
Returns
Type Description
ArraySegment<T>
| Improve this Doc View Source

ICollection<T>.Contains(T)

Declaration
bool ICollection<T>.Contains(T item)
Parameters
Type Name Description
T item
Returns
Type Description
Boolean
| Improve this Doc View Source

ICollection<T>.CopyTo(T[], Int32)

Declaration
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
Parameters
Type Name Description
T[] array
Int32 arrayIndex
| Improve this Doc View Source

ICollection<T>.Count

Declaration
int ICollection<T>.Count { get; }
Returns
Type Description
Int32
| Improve this Doc View Source

ICollection<T>.IsReadOnly

Declaration
bool ICollection<T>.IsReadOnly { get; }
Returns
Type Description
Boolean
| Improve this Doc View Source

ICollection<T>.Remove(T)

Declaration
bool ICollection<T>.Remove(T item)
Parameters
Type Name Description
T item
Returns
Type Description
Boolean
| Improve this Doc View Source

IList<T>.IndexOf(T)

Declaration
int IList<T>.IndexOf(T item)
Parameters
Type Name Description
T item
Returns
Type Description
Int32
| Improve this Doc View Source

IList<T>.Insert(Int32, T)

Declaration
void IList<T>.Insert(int index, T item)
Parameters
Type Name Description
Int32 index
T item
| Improve this Doc View Source

IList<T>.Item[Int32]

Declaration
T IList<T>.this[int index] { get; set; }
Parameters
Type Name Description
Int32 index
Returns
Type Description
T
| Improve this Doc View Source

IList<T>.RemoveAt(Int32)

Declaration
void IList<T>.RemoveAt(int index)
Parameters
Type Name Description
Int32 index

Implements

System.Buffers.IBufferWriter<T>
IConvertible<T>
System.Collections.Generic.IReadOnlyList<T>
System.Collections.Generic.IReadOnlyCollection<T>
IGrowableBuffer<T>
System.IDisposable
IConvertible<T>
System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>, out TResult1, out TResult2)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, Func<T, TResult1>, Func<T, TResult2>)
ObjectExtensions.Decompose<T, TResult1, TResult2>(T, ValueFunc<T, TResult1>, ValueFunc<T, TResult2>)
ObjectExtensions.As<T>(T)
BufferHelpers.Write<T>(IBufferWriter<T>, T)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
Collection.Convert<TInput, TOutput>(IReadOnlyCollection<TInput>, ValueFunc<TInput, TOutput>)
Collection.Convert<TInput, TOutput>(IReadOnlyCollection<TInput>, Converter<TInput, TOutput>)
Collection.AddAll<T>(ICollection<T>, IEnumerable<T>)
List.IndexerGetter<T>(IReadOnlyList<T>)
List.IndexerGetter<T>(IList<T>)
List.IndexerSetter<T>(IList<T>)
List.ToArray<TInput, TOutput>(IList<TInput>, ValueFunc<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, Converter<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, ValueFunc<Int32, TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, Func<Int32, TInput, TOutput>)
List.Convert<TInput, TOutput>(IReadOnlyList<TInput>, ValueFunc<TInput, TOutput>)
List.Convert<TInput, TOutput>(IReadOnlyList<TInput>, Converter<TInput, TOutput>)
List.InsertOrdered<T>(IList<T>, T, ValueFunc<T, T, Int32>)
List.InsertOrdered<T>(IList<T>, T, Comparison<T>)
List.Insert<T>(IList<T>, Index, T)
List.RemoveAt<T>(IList<T>, Index)
List.Slice<T>(IList<T>, Range)
Sequence.ToAsyncEnumerable<T>(IEnumerable<T>)
Sequence.GetAsyncEnumerator<T>(IEnumerable<T>, CancellationToken)
Sequence.ForEach<T>(IEnumerable<T>, Action<T>)
Sequence.ForEach<T>(IEnumerable<T>, ValueAction<T>)
Sequence.ForEachAsync<T>(IEnumerable<T>, Func<T, CancellationToken, ValueTask>, CancellationToken)
Sequence.ForEachAsync<T>(IEnumerable<T>, ValueFunc<T, CancellationToken, ValueTask>, CancellationToken)
Sequence.FirstOrEmpty<T>(IEnumerable<T>)
Sequence.FirstOrEmpty<T>(IEnumerable<T>, ValueFunc<T, Boolean>)
Sequence.FirstOrEmpty<T>(IEnumerable<T>, Predicate<T>)
Sequence.ElementAt<T>(IEnumerable<T>, Int32, out T)
Sequence.ToString<T>(IEnumerable<T>, String, String)
Sequence.Prepend<T>(IEnumerable<T>, T[])
Sequence.Append<T>(IEnumerable<T>, T[])
BufferWriter.Write<T>(IBufferWriter<T>, ReadOnlySequence<T>, CancellationToken)
BufferWriter.Write<T>(IBufferWriter<T>, T[], Int32, Int32)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX