FixedSizeBuffers

Class FixedSizeBuffer2<T>

A fixed size buffer of length 2.

Inheritance
Implements
Declaration
public sealed class FixedSizeBuffer2<T> : ValueType, IFixedSizeBuffer<T>
Type Parameters
Name Description

T

The type of the elements in the buffer

Fields

Item1

A slot in the buffer

Declaration
public T Item1
Field Value
Type Description

T

Item2

A slot in the buffer

Declaration
public T Item2
Field Value
Type Description

T

Properties

Item[Int32]

Gets or sets the element at offset index.

Declaration
public T this[int index] { get; set; }
Parameters
Type Name Description

Int32

index

The index

Property Value
Type Description

T

The element at offset index.

Exceptions
Type Condition

ArgumentOutOfRangeException

The index was outside the bounds of the buffer

Methods

AsReadOnlySpan()

Returns a ReadOnlySpan<T> representing the buffer.

This method is unsafe. You must ensure the ReadOnlySpan<T> does not outlive the buffer itself.

Declaration
public ReadOnlySpan<T> AsReadOnlySpan()
Returns
Type Description

ReadOnlySpan<T>

A ReadOnlySpan<T> representing the buffer.

AsSpan()

Returns a Span<T> representing the buffer.

This method is unsafe. You must ensure the Span<T> does not outlive the buffer itself.

Declaration
public Span<T> AsSpan()
Returns
Type Description

Span<T>

A Span<T> representing the buffer.

Dispose()

Call this method when you've finished using the buffer.

Technically this method is a no-op, but calling it ensures that the buffer is not deallocated before you've finished working with it.

Declaration
public void Dispose()

Implements

IFixedSizeBuffer<T>
System.IDisposable

Extension Methods

FixedSizeBufferExtensions.ItemRef<T>(ref FixedSizeBuffer2<T>, Int32)