Show / Hide Table of Contents

Class MemoryWriter<T>

Represents memory-backed output sink which T data can be written.

Inheritance
Object
Disposable
MemoryWriter<T>
PooledArrayBufferWriter<T>
PooledBufferWriter<T>
Implements
IBufferWriter<T>
IConvertible<ReadOnlyMemory<T>>
IReadOnlyList<T>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable
IGrowableBuffer<T>
IDisposable
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 abstract class MemoryWriter<T> : Disposable, IBufferWriter<T>, IConvertible<ReadOnlyMemory<T>>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IGrowableBuffer<T>, IDisposable
Type Parameters
Name Description
T

The data type that can be written.

Properties

| Improve this Doc View Source

AllocationCounter

Sets the counter used to report allocation of internal buffer.

Declaration
public EventCounter AllocationCounter { set; }
Property Value
Type Description
EventCounter
| Improve this Doc View Source

BufferSizeCallback

Sets the callback used internally to report actual size of allocated buffer.

Declaration
public Action<int> BufferSizeCallback { set; }
Property Value
Type Description
Action<Int32>
| Improve this Doc View Source

Capacity

Gets the total amount of space within the underlying memory.

Declaration
public abstract int Capacity { get; }
Property Value
Type Description
Int32
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

FreeCapacity

Gets the amount of space available that can still be written into without forcing the underlying buffer to grow.

Declaration
public int FreeCapacity { get; }
Property Value
Type Description
Int32
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
IndexOutOfRangeException

index the index is invalid.

ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

WrittenCount

Gets the amount of data written to the underlying memory so far.

Declaration
public int WrittenCount { get; }
Property Value
Type Description
Int32
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 abstract ReadOnlyMemory<T> WrittenMemory { get; }
Property Value
Type Description
ReadOnlyMemory<T>
Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

Methods

| Improve this Doc View Source

Add(T)

Writes single element.

Declaration
public void Add(T item)
Parameters
Type Name Description
T item

The element to write.

Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

AddAll(ICollection<T>)

Writes multiple elements.

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

The collection of elements to be copied.

Exceptions
Type Condition
ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

Advance(Int32)

Notifies this writer that count of data items were written.

Declaration
public void Advance(int count)
Parameters
Type Name Description
Int32 count

The number of data items written to the underlying buffer.

Exceptions
Type Condition
ArgumentOutOfRangeException

count is less than zero.

InvalidOperationException

Attempts to advance past the end of the underlying buffer.

ObjectDisposedException

This writer has been disposed.

| Improve this Doc View Source

Clear()

Clears the data written to the underlying memory.

Declaration
public virtual void 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 abstract void Clear(bool reuseBuffer)
Parameters
Type Name Description
Boolean reuseBuffer

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

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
Disposable.Dispose(Boolean)
| Improve this Doc View Source

GetEnumerator()

Gets enumerator over all written elements.

Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type Description
IEnumerator<T>

The enumerator over all written elements.

| Improve this Doc View Source

GetMemory(Int32)

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

Declaration
public abstract 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.

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

Exceptions
Type Condition
OutOfMemoryException

The requested buffer size is not available.

ObjectDisposedException

This writer has been disposed.

Explicit Interface Implementations

| Improve this Doc View Source

IGrowableBuffer<T>.CopyTo(Span<T>)

Declaration
int IGrowableBuffer<T>.CopyTo(Span<T> output)
Parameters
Type Name Description
Span<T> output
Returns
Type Description
Int32
| Improve this Doc View Source

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

Declaration
void IGrowableBuffer<T>.CopyTo<TState>(ReadOnlySpanAction<T, TState> callback, TState state)
Parameters
Type Name Description
ReadOnlySpanAction<T, TState> callback
TState state
Type Parameters
Name Description
TState
| Improve this Doc View Source

IGrowableBuffer<T>.Write(ReadOnlySpan<T>)

Declaration
void IGrowableBuffer<T>.Write(ReadOnlySpan<T> input)
Parameters
Type Name Description
ReadOnlySpan<T> input
| Improve this Doc View Source

IGrowableBuffer<T>.WrittenCount

Declaration
long IGrowableBuffer<T>.WrittenCount { get; }
Returns
Type Description
Int64
| Improve this Doc View Source

IConvertible<ReadOnlyMemory<T>>.Convert()

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

IReadOnlyCollection<T>.Count

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

IReadOnlyList<T>.Item[Int32]

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

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
IEnumerator

Implements

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

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>)
List.IndexerGetter<T>(IReadOnlyList<T>)
List.Convert<TInput, TOutput>(IReadOnlyList<TInput>, ValueFunc<TInput, TOutput>)
List.Convert<TInput, TOutput>(IReadOnlyList<TInput>, Converter<TInput, TOutput>)
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