Table of Contents

Class UnmanagedSpanExtensions

Namespace
NumSharp.Utilities
Assembly
NumSharp.dll

Extension methods for UnmanagedSpan{T} and ReadOnlyUnmanagedSpan{T}. These provide SIMD-accelerated operations where possible. All methods support full 64-bit indexing natively.

public static class UnmanagedSpanExtensions
Inheritance
UnmanagedSpanExtensions
Inherited Members

Methods

BinarySearch<T>(ReadOnlyUnmanagedSpan<T>, T)

Searches a sorted span for the specified value using binary search. Returns the index if found, or a negative number if not found. The negative number is the bitwise complement of the index where the value should be inserted.

public static long BinarySearch<T>(this ReadOnlyUnmanagedSpan<T> span, T value) where T : unmanaged, IComparable<T>

Parameters

span ReadOnlyUnmanagedSpan<T>
value T

Returns

long

Type Parameters

T

BinarySearch<T>(UnmanagedSpan<T>, T)

Searches a sorted span for the specified value using binary search. Returns the index if found, or a negative number if not found. The negative number is the bitwise complement of the index where the value should be inserted.

public static long BinarySearch<T>(this UnmanagedSpan<T> span, T value) where T : unmanaged, IComparable<T>

Parameters

span UnmanagedSpan<T>
value T

Returns

long

Type Parameters

T

Contains<T>(ReadOnlyUnmanagedSpan<T>, T)

Searches for the specified value and returns true if found. Uses SIMD acceleration for numeric types.

public static bool Contains<T>(this ReadOnlyUnmanagedSpan<T> span, T value) where T : unmanaged, IEquatable<T>

Parameters

span ReadOnlyUnmanagedSpan<T>
value T

Returns

bool

Type Parameters

T

Contains<T>(UnmanagedSpan<T>, T)

Searches for the specified value and returns true if found. Uses SIMD acceleration for numeric types.

public static bool Contains<T>(this UnmanagedSpan<T> span, T value) where T : unmanaged, IEquatable<T>

Parameters

span UnmanagedSpan<T>
value T

Returns

bool

Type Parameters

T

CopyTo<T>(ReadOnlyUnmanagedSpan<T>, UnmanagedSpan<T>)

Copies the contents of this span into a destination span.

public static void CopyTo<T>(this ReadOnlyUnmanagedSpan<T> source, UnmanagedSpan<T> destination) where T : unmanaged

Parameters

source ReadOnlyUnmanagedSpan<T>
destination UnmanagedSpan<T>

Type Parameters

T

EndsWith<T>(ReadOnlyUnmanagedSpan<T>, ReadOnlyUnmanagedSpan<T>)

Determines whether the span ends with the specified value.

public static bool EndsWith<T>(this ReadOnlyUnmanagedSpan<T> span, ReadOnlyUnmanagedSpan<T> value) where T : unmanaged, IEquatable<T>

Parameters

span ReadOnlyUnmanagedSpan<T>
value ReadOnlyUnmanagedSpan<T>

Returns

bool

Type Parameters

T

EndsWith<T>(UnmanagedSpan<T>, ReadOnlyUnmanagedSpan<T>)

Determines whether the span ends with the specified value.

public static bool EndsWith<T>(this UnmanagedSpan<T> span, ReadOnlyUnmanagedSpan<T> value) where T : unmanaged, IEquatable<T>

Parameters

span UnmanagedSpan<T>
value ReadOnlyUnmanagedSpan<T>

Returns

bool

Type Parameters

T

Fill<T>(UnmanagedSpan<T>, T)

Fills the span with the specified value. Uses SIMD acceleration for power-of-2 element sizes up to 8 bytes.

public static void Fill<T>(this UnmanagedSpan<T> span, T value) where T : unmanaged

Parameters

span UnmanagedSpan<T>
value T

Type Parameters

T

IndexOf<T>(ReadOnlyUnmanagedSpan<T>, T)

Searches for the specified value and returns the index of its first occurrence. Returns -1 if not found. Uses SIMD acceleration for numeric types.

public static long IndexOf<T>(this ReadOnlyUnmanagedSpan<T> span, T value) where T : unmanaged, IEquatable<T>

Parameters

span ReadOnlyUnmanagedSpan<T>
value T

Returns

long

Type Parameters

T

IndexOf<T>(UnmanagedSpan<T>, T)

Searches for the specified value and returns the index of its first occurrence. Returns -1 if not found. Uses SIMD acceleration for numeric types.

public static long IndexOf<T>(this UnmanagedSpan<T> span, T value) where T : unmanaged, IEquatable<T>

Parameters

span UnmanagedSpan<T>
value T

Returns

long

Type Parameters

T

LastIndexOf<T>(ReadOnlyUnmanagedSpan<T>, T)

Searches for the specified value and returns the index of its last occurrence. Returns -1 if not found. Uses SIMD acceleration for numeric types.

public static long LastIndexOf<T>(this ReadOnlyUnmanagedSpan<T> span, T value) where T : unmanaged, IEquatable<T>

Parameters

span ReadOnlyUnmanagedSpan<T>
value T

Returns

long

Type Parameters

T

LastIndexOf<T>(UnmanagedSpan<T>, T)

Searches for the specified value and returns the index of its last occurrence. Returns -1 if not found. Uses SIMD acceleration for numeric types.

public static long LastIndexOf<T>(this UnmanagedSpan<T> span, T value) where T : unmanaged, IEquatable<T>

Parameters

span UnmanagedSpan<T>
value T

Returns

long

Type Parameters

T

Reverse<T>(UnmanagedSpan<T>)

Reverses the elements in the span. Uses SIMD acceleration for power-of-2 element sizes.

public static void Reverse<T>(this UnmanagedSpan<T> span) where T : unmanaged

Parameters

span UnmanagedSpan<T>

Type Parameters

T

SequenceEqual<T>(ReadOnlyUnmanagedSpan<T>, ReadOnlyUnmanagedSpan<T>)

Determines whether two spans are equal by comparing elements using IEquatable{T}.Equals. Uses SIMD acceleration for numeric types.

public static bool SequenceEqual<T>(this ReadOnlyUnmanagedSpan<T> span, ReadOnlyUnmanagedSpan<T> other) where T : unmanaged, IEquatable<T>

Parameters

span ReadOnlyUnmanagedSpan<T>
other ReadOnlyUnmanagedSpan<T>

Returns

bool

Type Parameters

T

SequenceEqual<T>(UnmanagedSpan<T>, ReadOnlyUnmanagedSpan<T>)

Determines whether two spans are equal by comparing elements using IEquatable{T}.Equals. Uses SIMD acceleration for numeric types.

public static bool SequenceEqual<T>(this UnmanagedSpan<T> span, ReadOnlyUnmanagedSpan<T> other) where T : unmanaged, IEquatable<T>

Parameters

span UnmanagedSpan<T>
other ReadOnlyUnmanagedSpan<T>

Returns

bool

Type Parameters

T

StartsWith<T>(ReadOnlyUnmanagedSpan<T>, ReadOnlyUnmanagedSpan<T>)

Determines whether the span starts with the specified value.

public static bool StartsWith<T>(this ReadOnlyUnmanagedSpan<T> span, ReadOnlyUnmanagedSpan<T> value) where T : unmanaged, IEquatable<T>

Parameters

span ReadOnlyUnmanagedSpan<T>
value ReadOnlyUnmanagedSpan<T>

Returns

bool

Type Parameters

T

StartsWith<T>(UnmanagedSpan<T>, ReadOnlyUnmanagedSpan<T>)

Determines whether the span starts with the specified value.

public static bool StartsWith<T>(this UnmanagedSpan<T> span, ReadOnlyUnmanagedSpan<T> value) where T : unmanaged, IEquatable<T>

Parameters

span UnmanagedSpan<T>
value ReadOnlyUnmanagedSpan<T>

Returns

bool

Type Parameters

T

TryCopyTo<T>(ReadOnlyUnmanagedSpan<T>, UnmanagedSpan<T>)

Attempts to copy the contents of this span into a destination span. Returns false if the destination is too short.

public static bool TryCopyTo<T>(this ReadOnlyUnmanagedSpan<T> source, UnmanagedSpan<T> destination) where T : unmanaged

Parameters

source ReadOnlyUnmanagedSpan<T>
destination UnmanagedSpan<T>

Returns

bool

Type Parameters

T