Show / Hide Table of Contents

Class SparseBufferWriter<T>

Represents builder of the sparse memory buffer.

Inheritance
Object
Disposable
SparseBufferWriter<T>
Implements
IEnumerable<ReadOnlyMemory<T>>
IEnumerable
IGrowableBuffer<T>
IDisposable
IConvertible<ReadOnlySequence<T>>
IBufferWriter<T>
Inherited Members
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 class SparseBufferWriter<T> : Disposable, IEnumerable<ReadOnlyMemory<T>>, IEnumerable, IGrowableBuffer<T>, IDisposable, IConvertible<ReadOnlySequence<T>>, IBufferWriter<T>
Type Parameters
Name Description
T

The type of the elements in the memory.

Remarks

All members of IBufferWriter<T> are explicitly implemented because their usage can produce holes in the sparse buffer. To avoid holes, use public members only.

Constructors

| Improve this Doc View Source

SparseBufferWriter()

Initializes a new builder which uses Shared as a default allocator of buffers.

Declaration
public SparseBufferWriter()
| Improve this Doc View Source

SparseBufferWriter(MemoryPool<T>)

Initializes a new builder with automatically selected chunk size.

Declaration
public SparseBufferWriter(MemoryPool<T> pool)
Parameters
Type Name Description
MemoryPool<T> pool

Memory pool used to allocate memory chunks.

| Improve this Doc View Source

SparseBufferWriter(Int32, MemoryAllocator<T>)

Initializes a new builder with the specified size of memory block.

Declaration
public SparseBufferWriter(int chunkSize, MemoryAllocator<T> allocator = null)
Parameters
Type Name Description
Int32 chunkSize

The size of the memory block representing single segment within sequence.

MemoryAllocator<T> allocator

The allocator used to rent the segments.

Exceptions
Type Condition
ArgumentOutOfRangeException

chunkSize is less than or equal to zero.

Properties

| Improve this Doc View Source

WrittenCount

Gets the number of written elements.

Declaration
public long WrittenCount { get; }
Property Value
Type Description
Int64
Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

Methods

| Improve this Doc View Source

Clear()

Clears internal buffers so this builder can be reused.

Declaration
public void Clear()
Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

| Improve this Doc View Source

CopyTo(Span<T>)

Copies the contents of this builder to the specified memory block.

Declaration
public int CopyTo(Span<T> output)
Parameters
Type Name Description
Span<T> output

The memory block to be modified.

Returns
Type Description
Int32

The actual number of copied elements.

Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

| Improve this Doc View Source

CopyTo<TArg>(ReadOnlySpanAction<T, TArg>, TArg)

Passes the contents of this builder to the callback.

Declaration
public void CopyTo<TArg>(ReadOnlySpanAction<T, TArg> writer, TArg arg)
Parameters
Type Name Description
ReadOnlySpanAction<T, TArg> writer

The callback used to accept memory segments representing the contents of this builder.

TArg arg

The argument to be passed to the callback.

Type Parameters
Name Description
TArg

The type of the argument to tbe passed to the callback.

Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

| Improve this Doc View Source

Dispose(Boolean)

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing
Overrides
Disposable.Dispose(Boolean)
| Improve this Doc View Source

GetEnumerator()

Gets enumerator over memory segments.

Declaration
public SparseBufferWriter<T>.Enumerator GetEnumerator()
Returns
Type Description
SparseBufferWriter.Enumerator<>

The enumerator over memory segments.

Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

| Improve this Doc View Source

Write(ReadOnlySequence<T>, Boolean)

Writes a sequence of memory blocks to this builder.

Declaration
public void Write(in ReadOnlySequence<T> sequence, bool copyMemory = true)
Parameters
Type Name Description
ReadOnlySequence<T> sequence

A sequence of memory blocks.

Boolean copyMemory

true to copy the content of the input buffer; false to import memory blocks.

Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

| Improve this Doc View Source

Write(ReadOnlyMemory<T>, Boolean)

Writes the block of memory to this builder.

Declaration
public void Write(ReadOnlyMemory<T> input, bool copyMemory = true)
Parameters
Type Name Description
ReadOnlyMemory<T> input

The memory block to be written to this builder.

Boolean copyMemory

true to copy the content of the input buffer; false to import the memory block.

Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

| Improve this Doc View Source

Write(ReadOnlySpan<T>)

Writes the block of memory to this builder.

Declaration
public void Write(ReadOnlySpan<T> input)
Parameters
Type Name Description
ReadOnlySpan<T> input

The memory block to be written to this builder.

Exceptions
Type Condition
ObjectDisposedException

The builder has been disposed.

Explicit Interface Implementations

| Improve this Doc View Source

IConvertible<ReadOnlySequence<T>>.Convert()

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

IBufferWriter<T>.Advance(Int32)

Declaration
void IBufferWriter<T>.Advance(int count)
Parameters
Type Name Description
Int32 count
| Improve this Doc View Source

IBufferWriter<T>.GetMemory(Int32)

Declaration
Memory<T> IBufferWriter<T>.GetMemory(int sizeHint)
Parameters
Type Name Description
Int32 sizeHint
Returns
Type Description
Memory<T>
| Improve this Doc View Source

IBufferWriter<T>.GetSpan(Int32)

Declaration
Span<T> IBufferWriter<T>.GetSpan(int sizeHint)
Parameters
Type Name Description
Int32 sizeHint
Returns
Type Description
Span<T>
| Improve this Doc View Source

IEnumerable<ReadOnlyMemory<T>>.GetEnumerator()

Declaration
IEnumerator<ReadOnlyMemory<T>> IEnumerable<ReadOnlyMemory<T>>.GetEnumerator()
Returns
Type Description
IEnumerator<ReadOnlyMemory<T>>
| Improve this Doc View Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
IEnumerator

Implements

System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
IGrowableBuffer<T>
System.IDisposable
IConvertible<T>
System.Buffers.IBufferWriter<T>

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.ToReadOnlySequence<T>(IEnumerable<ReadOnlyMemory<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)
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.FirstOrNull<T>(IEnumerable<T>)
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)

See Also

PooledArrayBufferWriter<T>
PooledBufferWriter<T>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX