DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.12.4" />

 PooledArrayBufferWriter<T>

Represents memory writer that is backed by the array obtained from the pool.
public ref T this[int index] { get; }

Gets the element at the specified index.

public ref T this[long index] { get; }

Gets the element at the specified index.

public ArraySegment<T> WrittenArray { get; }

Gets the data written to the underlying array so far.

public PooledArrayBufferWriter(ArrayPool<T> pool, int initialCapacity)

Initializes a new writer with the specified initial capacity.

Initializes a new writer with the default initial capacity.

public PooledArrayBufferWriter(int initialCapacity)

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

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

public ArraySegment<T> GetArray(int sizeHint = 0)

Returns the memory to write to that is at least the requested size.

public void Insert(int index, ReadOnlySpan<T> items)

Inserts the elements into this buffer at the specified index.

public void Overwrite(int index, ReadOnlySpan<T> items)

Overwrites the elements in this buffer.

public void RemoveFirst(int count)

Removes the specified number of elements from the head of this buffer.

public void RemoveLast(int count)

Removes the specified number of elements from the tail of this buffer.