MemoryExtensions.SequenceCompareTo Method

Definition

Overloads

SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines the relative order of two read-only sequences by comparing their elements using IComparable{T}.CompareTo(T).

SequenceCompareTo<T>(Span<T>, ReadOnlySpan<T>)

Determines the relative order of a span and a read-only span by comparing the elements using IComparable{T}.CompareTo(T).

SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IComparer<T>)

SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Determines the relative order of two read-only sequences by comparing their elements using IComparable{T}.CompareTo(T).

C#
public static int SequenceCompareTo<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IComparable<T>;

Type Parameters

T

The type of elements in the sequence.

Parameters

span
ReadOnlySpan<T>

The first sequence to compare.

other
ReadOnlySpan<T>

The second sequence to compare.

Returns

A signed integer that indicates the relative order of span and other:
- If less than 0, span precedes than other.
- If 0, span equals other.
- If greater than 0, span follows other.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1

SequenceCompareTo<T>(Span<T>, ReadOnlySpan<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Determines the relative order of a span and a read-only span by comparing the elements using IComparable{T}.CompareTo(T).

C#
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int SequenceCompareTo<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IComparable<T>;
C#
public static int SequenceCompareTo<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IComparable<T>;

Type Parameters

T

The type of elements in the span.

Parameters

span
Span<T>

The span to compare.

other
ReadOnlySpan<T>

The read-only span to compare.

Returns

A signed integer that indicates the relative order of span and other:
- If less than 0, span precedes than other.
- If 0, span equals other.
- If greater than 0, span follows other.

Attributes

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1

SequenceCompareTo<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IComparer<T>)

C#
public static int SequenceCompareTo<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other, System.Collections.Generic.IComparer<T>? comparer = default);

Type Parameters

T

Parameters

comparer
IComparer<T>

Returns

Applies to

.NET 10
Product Versions
.NET 10