FixedSizeBuffers

Class WithFixedSizeBuffer<T>

Methods for running a function in the context of a stack-allocated buffer

Inheritance
  • Object
  • WithFixedSizeBuffer<T>
Declaration
public static class WithFixedSizeBuffer<T> : Object
Type Parameters
Name Description

T

The type of elements of the fixed-size buffer

Methods

Do(Int32, SpanAction<T>)

Stack-allocate a buffer with size elements, and pass it to action.

This method is unsafe. You must be careful not to use the Span<T> after action has returned.

Declaration
public static void Do(int size, SpanAction<T> action)
Parameters
Type Name Description

Int32

size

The size of the buffer

SpanAction<T>

action

The action to run

Do<U>(Int32, U, SpanAction<T, U>)

Stack-allocate a buffer with size elements, and pass it to action.

This method is unsafe. You must be careful not to use the Span<T> after action has returned.

Declaration
public static void Do<U>(int size, U arg, SpanAction<T, U> action)
Parameters
Type Name Description

Int32

size

The size of the buffer

U

arg

A state object to pass to action

SpanAction<T, U>

action

The action to run

Type Parameters
Name Description

U

Do<R>(Int32, SpanFunc<T, R>)

Stack-allocate a buffer with size elements, and pass it to func.

This method is unsafe. You must be careful not to use the Span<T> after func has returned.

Declaration
public static R Do<R>(int size, SpanFunc<T, R> func)
Parameters
Type Name Description

Int32

size

The size of the buffer

SpanFunc<T, R>

func

The action to run

Returns
Type Description

R

Type Parameters
Name Description

R

Do<U, R>(Int32, U, SpanFunc<T, U, R>)

Stack-allocate a buffer with size elements, and pass it to func.

This method is unsafe. You must be careful not to use the Span<T> after func has returned.

Declaration
public static R Do<U, R>(int size, U arg, SpanFunc<T, U, R> func)
Parameters
Type Name Description

Int32

size

The size of the buffer

U

arg

A state object to pass to func

SpanFunc<T, U, R>

func

The action to run

Returns
Type Description

R

Type Parameters
Name Description

U

R