Show / Hide Table of Contents

Struct SpanWriter<T>

Represents simple memory writer backed by Span<T>.

Inherited Members
ValueType.Equals(Object)
ValueType.GetHashCode()
ValueType.ToString()
Object.Equals(Object, Object)
Object.GetType()
Object.ReferenceEquals(Object, Object)
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public struct SpanWriter<T>
Type Parameters
Name Description
T

The type of elements in the span.

Constructors

| Improve this Doc View Source

SpanWriter(Span<T>)

Initializes a new memory writer.

Declaration
public SpanWriter(Span<T> span)
Parameters
Type Name Description
Span<T> span

The span used to write elements.

Properties

| Improve this Doc View Source

Current

Gets the element at the current position in the underlying memory block.

Declaration
public T Current { get; }
Property Value
Type Description
T
Exceptions
Type Condition
InvalidOperationException

The position of this writer is out of range.

| Improve this Doc View Source

FreeCapacity

Gets the available space in the underlying span.

Declaration
public int FreeCapacity { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

Span

Gets underlying span.

Declaration
public Span<T> Span { get; }
Property Value
Type Description
Span<T>
| Improve this Doc View Source

WrittenCount

Gets the number of occupied elements in the underlying span.

Declaration
public int WrittenCount { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

WrittenSpan

Gets the span over written elements.

Declaration
public Span<T> WrittenSpan { get; }
Property Value
Type Description
Span<T>

The segment of underlying span containing written elements.

Methods

| Improve this Doc View Source

Add(T)

Puts single element into the underlying span.

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

The item to place.

Exceptions
Type Condition
EndOfStreamException

Remaining space in the underlying span is not enough to place the item.

| Improve this Doc View Source

Reset()

Sets writer position to the first element.

Declaration
public void Reset()
| Improve this Doc View Source

Slide(Int32)

Obtains the portion of underlying span and marks it as written.

Declaration
public Span<T> Slide(int count)
Parameters
Type Name Description
Int32 count

The size of the segment.

Returns
Type Description
Span<T>

The portion of the underlying span.

Exceptions
Type Condition
EndOfStreamException

Remaining space in the underlying span is not enough to place count elements.

| Improve this Doc View Source

TryAdd(T)

Puts single element into the underlying span.

Declaration
public bool TryAdd(T item)
Parameters
Type Name Description
T item

The item to place.

Returns
Type Description
Boolean

true if item has beem placed successfully; false if remaining space in the underlying span is not enough to place the item.

| Improve this Doc View Source

TrySlide(Int32, out Span<T>)

Obtains the portion of underlying span and marks it as written.

Declaration
public bool TrySlide(int count, out Span<T> segment)
Parameters
Type Name Description
Int32 count

The size of the segment.

Span<T> segment

The portion of the underlying span.

Returns
Type Description
Boolean

true if segment is obtained successfully; false if remaining space in the underlying span is not enough to place count elements.

Exceptions
Type Condition
ArgumentOutOfRangeException

count is negative.

| Improve this Doc View Source

TryWrite(ReadOnlySpan<T>)

Copies the elements to the underlying span.

Declaration
public bool TryWrite(ReadOnlySpan<T> input)
Parameters
Type Name Description
ReadOnlySpan<T> input

The span to copy from.

Returns
Type Description
Boolean

true if all elements are copied successfully; false if remaining space in the underlying span is not enough to place all elements from input.

| Improve this Doc View Source

Write(ReadOnlySpan<T>)

Copies the elements to the underlying span.

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

The span of elements to copy from.

Returns
Type Description
Int32

The number of written elements.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX