ImmutableArray.BinarySearch 方法

定義

多載

BinarySearch<T>(ImmutableArray<T>, T)

使用預設的比較子搜尋指定項目已排序的不可變陣列,並在找到時,傳回該項目以零為起始的索引。

BinarySearch<T>(ImmutableArray<T>, T, IComparer<T>)

搜尋指定項目已排序的不可變陣列,並在找到時,傳回該項目以零為起始的索引。

BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T)

搜尋指定項目已排序的不可變陣列,並在找到時,傳回該項目以零為起始的索引。

BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T, IComparer<T>)

搜尋指定項目已排序的不可變陣列,並傳回該項目以零為起始的索引。

BinarySearch<T>(ImmutableArray<T>, T)

來源:
ImmutableArray.cs
來源:
ImmutableArray.cs
來源:
ImmutableArray.cs

使用預設的比較子搜尋指定項目已排序的不可變陣列,並在找到時,傳回該項目以零為起始的索引。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, T value);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, T value);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * 'T -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), value As T) As Integer

類型參數

T

陣列中儲存之項目的型別。

參數

array
ImmutableArray<T>

要搜尋的已排序陣列。

value
T

要搜尋的物件。

傳回

如果有找到項目,則為陣列中項目之以零為起始的索引,否則便為負數,此負數為大於 value 的下一個項目索引之位元補數,或者,如果沒有更大的項目,則為 Count 的位元補數。

例外狀況

value 不實作 IComparable,或搜尋遇到不實作 IComparable 的項目。

適用於

BinarySearch<T>(ImmutableArray<T>, T, IComparer<T>)

來源:
ImmutableArray.cs
來源:
ImmutableArray.cs
來源:
ImmutableArray.cs

搜尋指定項目已排序的不可變陣列,並在找到時,傳回該項目以零為起始的索引。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, T value, System::Collections::Generic::IComparer<T> ^ comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, T value, System.Collections.Generic.IComparer<T> comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, T value, System.Collections.Generic.IComparer<T>? comparer);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * 'T * System.Collections.Generic.IComparer<'T> -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), value As T, comparer As IComparer(Of T)) As Integer

類型參數

T

陣列中儲存之項目的型別。

參數

array
ImmutableArray<T>

要搜尋的已排序陣列。

value
T

要搜尋的物件。

comparer
IComparer<T>

比較項目時要使用的比較子實作,或 null 表示使用預設比較子。

傳回

如果有找到項目,則為陣列中項目之以零為起始的索引,否則便為負數,此負數為大於 value 的下一個項目索引之位元補數,或者,如果沒有更大的項目,則為 Count 的位元補數。

例外狀況

comparer 為 Null 且 value 不實作 IComparable,或搜尋遇到不實作 IComparable 的項目。

適用於

BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T)

來源:
ImmutableArray.cs
來源:
ImmutableArray.cs
來源:
ImmutableArray.cs

搜尋指定項目已排序的不可變陣列,並在找到時,傳回該項目以零為起始的索引。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, int index, int length, T value);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, int index, int length, T value);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * int * int * 'T -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), index As Integer, length As Integer, value As T) As Integer

類型參數

T

陣列中儲存之項目的型別。

參數

array
ImmutableArray<T>

要搜尋的已排序陣列。

index
Int32

要搜尋範圍的起始索引。

length
Int32

搜尋範圍的長度。

value
T

要搜尋的物件。

傳回

如果有找到項目,則為陣列中項目之以零為起始的索引,否則便為負數,此負數為大於 value 的下一個項目索引之位元補數,或者,如果沒有更大的項目,則為 Count 的位元補數。

例外狀況

value 不實作 IComparable,或搜尋遇到不實作 IComparable 的項目。

indexlength 未指定 array 中的有效範圍。

index 小於 array 的下限。

-或-

length 小於零。

適用於

BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T, IComparer<T>)

來源:
ImmutableArray.cs
來源:
ImmutableArray.cs
來源:
ImmutableArray.cs

搜尋指定項目已排序的不可變陣列,並傳回該項目以零為起始的索引。

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, int index, int length, T value, System::Collections::Generic::IComparer<T> ^ comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, int index, int length, T value, System.Collections.Generic.IComparer<T> comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, int index, int length, T value, System.Collections.Generic.IComparer<T>? comparer);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * int * int * 'T * System.Collections.Generic.IComparer<'T> -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), index As Integer, length As Integer, value As T, comparer As IComparer(Of T)) As Integer

類型參數

T

陣列中儲存之項目的型別。

參數

array
ImmutableArray<T>

要搜尋的已排序陣列。

index
Int32

要搜尋範圍的起始索引。

length
Int32

搜尋範圍的長度。

value
T

要搜尋的物件。

comparer
IComparer<T>

比較項目是否相等時要使用的比較子,或 null 表示使用預設比較子。

傳回

如果有找到項目,則為陣列中項目之以零為起始的索引,否則便為負數,此負數為大於 value 的下一個項目索引之位元補數,或者,如果沒有更大的項目,則為 Count 的位元補數。

例外狀況

comparer 為 Null 且 value 不實作 IComparable,或搜尋遇到不實作 IComparable 的項目。

indexlength 未指定 array 中的有效範圍。

-或-

comparernull,且 value 的類型與 array 項目不相容。

index 小於 array 的下限。

-或-

length 小於零。

適用於