CommunityToolkit.HighPerformance Namespace

Classes

ArrayExtensions

Helpers for working with the Array type.

ArrayPoolBufferWriterExtensions

Helpers for working with the ArrayPoolBufferWriter<T> type.

ArrayPoolExtensions

Helpers for working with the ArrayPool<T> type.

BoolExtensions

Helpers for working with the Boolean type.

Box<T>

A class that represents a boxed T value on the managed heap. This is a "shadow" type that can be used in place of a non-generic Object reference to a boxed value type, to make the code more expressive and reduce the chances of errors. Consider this example:

object obj = 42;

// Manual, error prone unboxing
int sum = (int)obj + 1;

In this example, it is not possible to know in advance what type is actually being boxed in a given Object instance, making the code less robust at build time. The Box<T> type can be used as a drop-in replacement in this case, like so:

Box<int> box = 42;

// Build-time validation, automatic unboxing
int sum = box.Value + 1;

This type can also be useful when dealing with large custom value types that are also boxed, as it allows to retrieve a mutable reference to the boxing value. This means that a given boxed value can be mutated in-place, instead of having to allocate a new updated boxed instance.

BoxExtensions

Helpers for working with the Box<T> type.

HashCodeExtensions

Helpers for working with the HashCode type.

IBufferWriterExtensions

Helpers for working with the IBufferWriter<T> type.

IMemoryOwnerExtensions

Helpers for working with the IMemoryOwner<T> type.

MemoryExtensions

Helpers for working with the Memory<T> type.

ReadOnlyMemoryExtensions

Helpers for working with the ReadOnlyMemory<T> type.

ReadOnlySpanExtensions

Helpers for working with the ReadOnlySpan<T> type.

SpanExtensions

Helpers for working with the Span<T> type.

SpinLockExtensions

Helpers for working with the SpinLock type.

StreamExtensions

Helpers for working with the Stream type.

StringExtensions

Helpers for working with the String type.

Structs

Memory2D<T>

Memory2D<T> represents a 2D region of arbitrary memory. It is to Span2D<T> what Memory<T> is to Span<T>. For further details on how the internal layout is structured, see the docs for Span2D<T>. The Memory2D<T> type can wrap arrays of any rank, provided that a valid series of parameters for the target memory area(s) are specified.

ReadOnlyMemory2D<T>

A readonly version of Memory2D<T>.

ReadOnlyRef<T>

A struct that can store a readonly reference to a value of a specified type.

ReadOnlySpan2D<T>.Enumerator

Provides an enumerator for the elements of a ReadOnlySpan2D<T> instance.

ReadOnlySpan2D<T>
Ref<T>

A struct that can store a reference to a value of a specified type.

Span2D<T>.Enumerator

Provides an enumerator for the elements of a Span2D<T> instance.

Span2D<T>
SpinLockExtensions.Lock

A struct that is used to enter and hold a SpinLock through a using block or statement.

SpinLockExtensions.UnsafeLock

A struct that is used to enter and hold a SpinLock through a using block or statement.