DotNext by .NET Foundation and Contributors

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

.NET API 516,184 bytes

 BufferWriterSlim<T>

public struct BufferWriterSlim<T>
Represents stack-allocated buffer writer.
public int Capacity { get; }

Gets the total amount of space within the underlying memory.

public int FreeCapacity { get; }

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

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

Gets the element at the specified zero-based index within this builder.

public int WrittenCount { get; set; }

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

public ReadOnlySpan<T> WrittenSpan { get; }

Gets span over constructed memory block.

public BufferWriterSlim(Span<T> buffer, MemoryAllocator<T> allocator = null)

Initializes growable buffer.

public BufferWriterSlim(int initialCapacity, MemoryAllocator<T> allocator = null)

Initializes growable buffer.

public void Add(T item)

Adds single element to this builder.

public ref T Add()

Adds single element and returns a reference to it.

public void Advance(int count)

Notifies this writer that count of data items were written.

public void Clear(bool reuseBuffer = false)

Clears the data written to the underlying buffer.

public void Dispose()

Releases internal buffer used by this builder.

public Span<T> GetSpan(int sizeHint = 0)

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

public void Rewind(int count)

Moves the writer back the specified number of items.

public bool TryDetachBuffer(out MemoryOwner owner)

Detaches the underlying buffer with written content from this writer.

public bool TryPeek(out T item)

Gets the last added item.

public bool TryPop(out T item)

Attempts to remove the last added item.

public bool TryPop(Span<T> output)

Attempts to remove a sequence of last added items.

public void Write(ReadOnlySpan<T> input)

Writes elements to this buffer.