Show / Hide Table of Contents

Class PoolingArrayBufferWriter<T>

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

Inheritance
object
Disposable
BufferWriter<T>
PoolingArrayBufferWriter<T>
Implements
IBufferWriter<T>
ISupplier<ReadOnlyMemory<T>>
IFunctional<Func<ReadOnlyMemory<T>>>
IReadOnlyList<T>
IReadOnlyCollection<T>
IGrowableBuffer<T>
IReadOnlySpanConsumer<T>
ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>
IFunctional<Func<ReadOnlyMemory<T>, CancellationToken, ValueTask>>
IDisposable
IResettable
ISupplier<ArraySegment<T>>
IFunctional<Func<ArraySegment<T>>>
IList<T>
ICollection<T>
IEnumerable<T>
IEnumerable
Inherited Members
BufferWriter<T>.MeasurementTags
BufferWriter<T>.WrittenCount
BufferWriter<T>.Add(T)
BufferWriter<T>.FreeCapacity
BufferWriter<T>.Advance(int)
BufferWriter<T>.Rewind(int)
BufferWriter<T>.GetEnumerator()
BufferWriter<T>.ToString()
Disposable.Dispose()
Disposable.Dispose(IEnumerable<IDisposable>)
Disposable.DisposeAsync(IEnumerable<IAsyncDisposable>)
Disposable.Dispose<T>(ReadOnlySpan<T>)
Disposable.DisposeAsync(params IAsyncDisposable[])
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public sealed class PoolingArrayBufferWriter<T> : BufferWriter<T>, IBufferWriter<T>, ISupplier<ReadOnlyMemory<T>>, IFunctional<Func<ReadOnlyMemory<T>>>, IReadOnlyList<T>, IReadOnlyCollection<T>, IGrowableBuffer<T>, IReadOnlySpanConsumer<T>, ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>, IFunctional<Func<ReadOnlyMemory<T>, CancellationToken, ValueTask>>, IDisposable, IResettable, ISupplier<ArraySegment<T>>, IFunctional<Func<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 PoolingBufferWriter<T>.

Constructors

| Edit this page View Source

PoolingArrayBufferWriter(ArrayPool<T>?)

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

Declaration
public PoolingArrayBufferWriter(ArrayPool<T>? pool = null)
Parameters
Type Name Description
ArrayPool<T> pool

The array pool.

Remarks

This class provides additional methods for access to array segments in contrast to PoolingBufferWriter<T>.

Properties

| Edit this page View Source

Capacity

Gets or sets the total amount of space within the underlying memory.

Declaration
public override int Capacity { get; init; }
Property Value
Type Description
int
Overrides
BufferWriter<T>.Capacity
Exceptions
Type Condition
ArgumentOutOfRangeException

value is less than zero.

| Edit this page View Source

this[int]

Gets the element at the specified index.

Declaration
public ref T this[int index] { get; }
Parameters
Type Name Description
int 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.

| Edit this page View Source

WrittenArray

Gets the data 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.

| Edit this page 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
BufferWriter<T>.WrittenMemory
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

Methods

| Edit this page View Source

AddAll(ICollection<T>)

Writes multiple elements.

Declaration
public override void AddAll(ICollection<T> items)
Parameters
Type Name Description
ICollection<T> items

The collection of elements to be copied.

Overrides
BufferWriter<T>.AddAll(ICollection<T>)
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Edit this page View Source

Clear(bool)

Clears the data written to the underlying memory.

Declaration
public override void Clear(bool reuseBuffer = false)
Parameters
Type Name Description
bool reuseBuffer

true to reuse the internal buffer; false to destroy the internal buffer.

Overrides
BufferWriter<T>.Clear(bool)
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Edit this page View Source

DetachBuffer()

Transfers ownership of the written memory from this writer to the caller.

Declaration
public override MemoryOwner<T> DetachBuffer()
Returns
Type Description
MemoryOwner<T>

The object representing all written content.

Overrides
BufferWriter<T>.DetachBuffer()
Remarks

The caller is responsible for the lifetime of the returned buffer. The current state of this writer will be reset.

Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Edit this page View Source

Dispose(bool)

Releases managed and unmanaged resources associated with this object.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

true if called from Dispose(); false if called from finalizer ~Disposable().

Overrides
BufferWriter<T>.Dispose(bool)
| Edit this page View Source

GetArray(int)

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

| Edit this page View Source

GetMemory(int)

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

The minimum length of the returned memory.

Returns
Type Description
Memory<T>

The memory block of at least the size sizeHint.

Overrides
BufferWriter<T>.GetMemory(int)
Exceptions
Type Condition
OutOfMemoryException

The requested buffer size is not available.

ObjectDisposedException

This writer has been disposed.

| Edit this page View Source

GetSpan(int)

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

The minimum length of the returned memory.

Returns
Type Description
Span<T>

The memory block of at least the size sizeHint.

Overrides
BufferWriter<T>.GetSpan(int)
Exceptions
Type Condition
OutOfMemoryException

The requested buffer size is not available.

ObjectDisposedException

This writer has been disposed.

| Edit this page View Source

Insert(int, ReadOnlySpan<T>)

Inserts the elements into this buffer at the specified index.

Declaration
public void Insert(int index, ReadOnlySpan<T> items)
Parameters
Type Name Description
int index

The zero-based index at which the new elements should be inserted.

ReadOnlySpan<T> items

The span whose elements should be inserted into this buffer.

Exceptions
Type Condition
ArgumentOutOfRangeException

index the index is invalid.

ObjectDisposedException

This writer has been disposed.

| Edit this page View Source

Overwrite(int, ReadOnlySpan<T>)

Overwrites the elements in this buffer.

Declaration
public void Overwrite(int index, ReadOnlySpan<T> items)
Parameters
Type Name Description
int index

The zero-based index at which the new elements should be rewritten.

ReadOnlySpan<T> items

The span whose elements should be added into this buffer.

Exceptions
Type Condition
ArgumentOutOfRangeException

index the index is invalid.

ObjectDisposedException

This writer has been disposed.

| Edit this page View Source

RemoveFirst(int)

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

Declaration
public void RemoveFirst(int count)
Parameters
Type Name Description
int 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.

| Edit this page View Source

RemoveLast(int)

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

Declaration
public void RemoveLast(int count)
Parameters
Type Name Description
int 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.

Implements

IBufferWriter<T>
ISupplier<TResult>
IFunctional<TDelegate>
IReadOnlyList<T>
IReadOnlyCollection<T>
IGrowableBuffer<T>
IReadOnlySpanConsumer<T>
ISupplier<T1, T2, TResult>
IFunctional<TDelegate>
IDisposable
IResettable
ISupplier<TResult>
IFunctional<TDelegate>
IList<T>
ICollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
BufferWriter.Write<T>(IBufferWriter<T>, in ReadOnlySequence<T>)
Collection.AddAll<T>(ICollection<T>, IEnumerable<T>)
Collection.Append<T>(IEnumerable<T>, params T[])
Collection.Copy<T>(IEnumerable<T>, int, MemoryAllocator<T>?)
Collection.ElementAt<T>(IEnumerable<T>, int, out T)
Collection.FirstOrNone<T>(IEnumerable<T>)
Collection.ForEachAsync<T>(IEnumerable<T>, Func<T, CancellationToken, ValueTask>, CancellationToken)
Collection.ForEach<T>(IEnumerable<T>, Action<T>)
Collection.LastOrNone<T>(IEnumerable<T>)
Collection.Prepend<T>(IEnumerable<T>, params T[])
Collection.SequenceHashCode<T>(IEnumerable<T>, bool)
Collection.ToAsyncEnumerable<T>(IEnumerable<T>)
Collection.ToString<T>(IEnumerable<T>, string, string)
Enumerator.GetAsyncEnumerator<T>(IEnumerable<T>, CancellationToken)
List.IndexerGetter<T>(IList<T>)
List.IndexerSetter<T>(IList<T>)
List.InsertOrdered<T>(IList<T>, T, delegate*<T?, T?, int>)
List.InsertOrdered<T>(IList<T>, T, Comparison<T?>)
List.InsertOrdered<T, TComparer>(IList<T>, T, TComparer)
List.Insert<T>(IList<T>, Index, T)
List.RemoveAt<T>(IList<T>, Index)
List.Slice<T>(IList<T>, Range)
List.ToArray<TInput, TOutput>(IList<TInput>, delegate*<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, delegate*<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, Converter<TInput, TOutput>)
List.ToArray<TInput, TOutput>(IList<TInput>, Func<int, TInput, TOutput>)
Collection.Convert<TInput, TOutput>(IReadOnlyCollection<TInput>, Converter<TInput, TOutput>)
List.Convert<TInput, TOutput>(IReadOnlyList<TInput>, Converter<TInput, TOutput>)
List.IndexerGetter<T>(IReadOnlyList<T>)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾