ArrayPoolBufferWriter<T> Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a heap-based, array-backed output sink into which T
data can be written.
public sealed class ArrayPoolBufferWriter<T> : CommunityToolkit.HighPerformance.Buffers.IBuffer<T>, System.Buffers.IBufferWriter<T>, System.Buffers.IMemoryOwner<T>
public sealed class ArrayPoolBufferWriter<T> : CommunityToolkit.HighPerformance.Buffers.IBuffer<T>, IDisposable, System.Buffers.IBufferWriter<T>, System.Buffers.IMemoryOwner<T>
type ArrayPoolBufferWriter<'T> = class
interface IBuffer<'T>
interface IBufferWriter<'T>
interface IMemoryOwner<'T>
interface IDisposable
Public NotInheritable Class ArrayPoolBufferWriter(Of T)
Implements IBuffer(Of T), IBufferWriter(Of T), IMemoryOwner(Of T)
Public NotInheritable Class ArrayPoolBufferWriter(Of T)
Implements IBuffer(Of T), IBufferWriter(Of T), IDisposable, IMemoryOwner(Of T)
Type Parameters
- T
The type of items to write to the current instance.
- Inheritance
-
ArrayPoolBufferWriter<T>
- Implements
Remarks
This is a custom IBufferWriter<T> implementation that replicates the functionality and API surface of the array-based buffer writer available in .NET Standard 2.1, with the main difference being the fact that in this case the arrays in use are rented from the shared ArrayPool<T> instance, and that ArrayPoolBufferWriter<T> is also available on .NET Standard 2.0.
Constructors
ArrayPoolBufferWriter<T>() |
Initializes a new instance of the ArrayPoolBufferWriter<T> class. |
ArrayPoolBufferWriter<T>(ArrayPool<T>, Int32) |
Initializes a new instance of the ArrayPoolBufferWriter<T> class. |
ArrayPoolBufferWriter<T>(ArrayPool<T>) |
Initializes a new instance of the ArrayPoolBufferWriter<T> class. |
ArrayPoolBufferWriter<T>(Int32) |
Initializes a new instance of the ArrayPoolBufferWriter<T> class. |
Properties
Capacity |
Gets the total amount of space within the underlying buffer. |
FreeCapacity |
Gets the amount of space available that can still be written into without forcing the underlying buffer to grow. |
WrittenCount |
Gets the amount of data written to the underlying buffer so far. |
WrittenMemory |
Gets the data written to the underlying buffer so far, as a ReadOnlyMemory<T>. |
WrittenSpan |
Gets the data written to the underlying buffer so far, as a ReadOnlySpan<T>. |
Methods
Advance(Int32) | Notifies the IBufferWriter<T> that |
Clear() |
Clears the data written to the underlying buffer. |
DangerousGetArray() |
Gets an ArraySegment<T> instance wrapping the underlying |
Dispose() |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
Finalize() |
Finalizes an instance of the ArrayPoolBufferWriter<T> class. |
GetMemory(Int32) | Returns a Memory<T> to write to that is at least the requested size (specified by |
GetSpan(Int32) | Returns a Span<T> to write to that is at least the requested size (specified by |
ToString() |
Returns a string that represents the current object. |
Explicit Interface Implementations
IMemoryOwner<T>.Memory | Gets the memory belonging to this owner. |
Extension Methods
Write<T>(IBufferWriter<T>, T) |
Writes a value of a specified type into a target IBufferWriter<T> instance. |
Write<T>(IBufferWriter<T>, ReadOnlySpan<T>) | |
Write<T>(IBufferWriter<T>, T) |
Writes a value of a specified type into a target IBufferWriter<T> instance. |