Επεξεργασία

Κοινή χρήση μέσω


MemoryExtensions.BinarySearch Method

Definition

Overloads

BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable)

Searches an entire sorted ReadOnlySpan<T> for a value using the specified TComparable generic type.

BinarySearch<T,TComparable>(Span<T>, TComparable)

Searches an entire sorted Span<T> for a value using the specified TComparable generic type.

BinarySearch<T,TComparer>(Span<T>, T, TComparer)

Searches an entire sorted Span<T> for a specified value using the specified TComparer generic type.

BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer)

Searches an entire sorted ReadOnlySpan<T> for a specified value using the specified TComparer generic type.

BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>)

Searches an entire sorted ReadOnlySpan<T> for a value using the specified IComparable<T> generic interface.

BinarySearch<T>(Span<T>, IComparable<T>)

Searches an entire sorted Span<T> for a value using the specified IComparable<T> generic interface.

BinarySearch<T,TComparable>(ReadOnlySpan<T>, TComparable)

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

Searches an entire sorted ReadOnlySpan<T> for a value using the specified TComparable generic type.

public:
generic <typename T, typename TComparable>
 where TComparable : IComparable<T>[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(ReadOnlySpan<T> span, TComparable comparable);
public static int BinarySearch<T,TComparable> (this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T>;
static member BinarySearch : ReadOnlySpan<'T> * 'Comparable -> int (requires 'Comparable :> IComparable<'T>)
<Extension()>
Public Function BinarySearch(Of T, TComparable) (span As ReadOnlySpan(Of T), comparable As TComparable) As Integer

Type Parameters

T

The element type of the span.

TComparable

The specific type of IComparable<T>.

Parameters

span
ReadOnlySpan<T>

The sorted ReadOnlySpan<T> to search.

comparable
TComparable

The TComparable to use when comparing.

Returns

The zero-based index of comparable in the sorted span, if comparable is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than comparable or, if there is no larger element, the bitwise complement of Length.

Exceptions

comparable is null.

Applies to

BinarySearch<T,TComparable>(Span<T>, TComparable)

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

Searches an entire sorted Span<T> for a value using the specified TComparable generic type.

public:
generic <typename T, typename TComparable>
 where TComparable : IComparable<T>[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(Span<T> span, TComparable comparable);
public static int BinarySearch<T,TComparable> (this Span<T> span, TComparable comparable) where TComparable : IComparable<T>;
static member BinarySearch : Span<'T> * 'Comparable -> int (requires 'Comparable :> IComparable<'T>)
<Extension()>
Public Function BinarySearch(Of T, TComparable) (span As Span(Of T), comparable As TComparable) As Integer

Type Parameters

T

The element type of the span.

TComparable

The specific type of IComparable<T>.

Parameters

span
Span<T>

The sorted Span<T> to search.

comparable
TComparable

The TComparable to use when comparing.

Returns

The zero-based index of comparable in the sorted span, if comparable is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than comparable or, if there is no larger element, the bitwise complement of Length.

Exceptions

comparable is null.

Applies to

BinarySearch<T,TComparer>(Span<T>, T, TComparer)

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

Searches an entire sorted Span<T> for a specified value using the specified TComparer generic type.

public:
generic <typename T, typename TComparer>
 where TComparer : System::Collections::Generic::IComparer<T>[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(Span<T> span, T value, TComparer comparer);
public static int BinarySearch<T,TComparer> (this Span<T> span, T value, TComparer comparer) where TComparer : System.Collections.Generic.IComparer<T>;
static member BinarySearch : Span<'T> * 'T * 'Comparer -> int (requires 'Comparer :> System.Collections.Generic.IComparer<'T>)
<Extension()>
Public Function BinarySearch(Of T, TComparer) (span As Span(Of T), value As T, comparer As TComparer) As Integer

Type Parameters

T

The element type of the span.

TComparer

The specific type of IComparer<T>.

Parameters

span
Span<T>

The sorted Span<T> to search.

value
T

The object to locate. The value can be null for reference types.

comparer
TComparer

The TComparer to use when comparing.

Returns

The zero-based index of value in the sorted span, if value is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Length.

Exceptions

comparer is null.

Applies to

BinarySearch<T,TComparer>(ReadOnlySpan<T>, T, TComparer)

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

Searches an entire sorted ReadOnlySpan<T> for a specified value using the specified TComparer generic type.

public:
generic <typename T, typename TComparer>
 where TComparer : System::Collections::Generic::IComparer<T>[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(ReadOnlySpan<T> span, T value, TComparer comparer);
public static int BinarySearch<T,TComparer> (this ReadOnlySpan<T> span, T value, TComparer comparer) where TComparer : System.Collections.Generic.IComparer<T>;
static member BinarySearch : ReadOnlySpan<'T> * 'T * 'Comparer -> int (requires 'Comparer :> System.Collections.Generic.IComparer<'T>)
<Extension()>
Public Function BinarySearch(Of T, TComparer) (span As ReadOnlySpan(Of T), value As T, comparer As TComparer) As Integer

Type Parameters

T

The element type of the span.

TComparer

The specific type of IComparer<T>.

Parameters

span
ReadOnlySpan<T>

The sorted ReadOnlySpan<T> to search.

value
T

The object to locate. The value can be null for reference types.

comparer
TComparer

The TComparer to use when comparing.

Returns

The zero-based index of value in the sorted span, if value is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than value or, if there is no larger element, the bitwise complement of Length.

Exceptions

comparer is null.

Applies to

BinarySearch<T>(ReadOnlySpan<T>, IComparable<T>)

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

Searches an entire sorted ReadOnlySpan<T> for a value using the specified IComparable<T> generic interface.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(ReadOnlySpan<T> span, IComparable<T> ^ comparable);
public static int BinarySearch<T> (this ReadOnlySpan<T> span, IComparable<T> comparable);
static member BinarySearch : ReadOnlySpan<'T> * IComparable<'T> -> int
<Extension()>
Public Function BinarySearch(Of T) (span As ReadOnlySpan(Of T), comparable As IComparable(Of T)) As Integer

Type Parameters

T

The element type of the span.

Parameters

span
ReadOnlySpan<T>

The sorted ReadOnlySpan<T> to search.

comparable
IComparable<T>

The IComparable<T> to use when comparing.

Returns

The zero-based index of comparable in the sorted span, if comparable is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than comparable or, if there is no larger element, the bitwise complement of Length.

Exceptions

comparable is null.

Applies to

BinarySearch<T>(Span<T>, IComparable<T>)

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

Searches an entire sorted Span<T> for a value using the specified IComparable<T> generic interface.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(Span<T> span, IComparable<T> ^ comparable);
public static int BinarySearch<T> (this Span<T> span, IComparable<T> comparable);
static member BinarySearch : Span<'T> * IComparable<'T> -> int
<Extension()>
Public Function BinarySearch(Of T) (span As Span(Of T), comparable As IComparable(Of T)) As Integer

Type Parameters

T

The element type of the span.

Parameters

span
Span<T>

The sorted Span<T> to search.

comparable
IComparable<T>

The IComparable<T> to use when comparing.

Returns

The zero-based index of comparable in the sorted span, if comparable is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than comparable or, if there is no larger element, the bitwise complement of Length.

Exceptions

comparable is null.

Applies to