ImmutableList<T>.Builder.BinarySearch 方法

定義

多載

BinarySearch(T)

使用預設的比較子來搜尋項目的整個 ImmutableList<T>.Builder,並傳回項目以零為起始的索引。

BinarySearch(T, IComparer<T>)

使用指定的比較子並傳回項目以零為起始的索引,來搜尋項目的整個 ImmutableList<T>.Builder

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

使用指定的比較子來搜尋項目之指定範圍的 ImmutableList<T>.Builder,並傳回項目以零為起始的索引。

BinarySearch(T)

來源:
ImmutableList_1.Builder.cs
來源:
ImmutableList_1.Builder.cs
來源:
ImmutableList_1.Builder.cs

使用預設的比較子來搜尋項目的整個 ImmutableList<T>.Builder,並傳回項目以零為起始的索引。

public:
 virtual int BinarySearch(T item);
public:
 int BinarySearch(T item);
public int BinarySearch (T item);
abstract member BinarySearch : 'T -> int
override this.BinarySearch : 'T -> int
member this.BinarySearch : 'T -> int
Public Function BinarySearch (item As T) As Integer

參數

item
T

要尋找的物件。 參考類型的值可以是 Null。

傳回

如果找到項目,則為 ImmutableList<T>.Builder 中項目以零為起始的索引,否則為負數,此負數是大於 item 之下一個項目索引的位元補數。

例外狀況

預設比較子 Default 找不到 IComparable<T> 泛型介面實作或類型 T 的 IComparable 介面。

備註

ImmutableList<T>.Builder如果 不包含指定的值,則方法會傳回負整數。 您可以將位補碼運算 (~) 套用至這個負整數,以取得大於搜尋值的第一個專案索引。 將值插入 至 ImmutableList<T>.Builder時,這個索引應該當做插入點使用,以維護排序順序。

適用於

BinarySearch(T, IComparer<T>)

來源:
ImmutableList_1.Builder.cs
來源:
ImmutableList_1.Builder.cs
來源:
ImmutableList_1.Builder.cs

使用指定的比較子並傳回項目以零為起始的索引,來搜尋項目的整個 ImmutableList<T>.Builder

public:
 virtual int BinarySearch(T item, System::Collections::Generic::IComparer<T> ^ comparer);
public:
 int BinarySearch(T item, System::Collections::Generic::IComparer<T> ^ comparer);
public int BinarySearch (T item, System.Collections.Generic.IComparer<T> comparer);
public int BinarySearch (T item, System.Collections.Generic.IComparer<T>? comparer);
abstract member BinarySearch : 'T * System.Collections.Generic.IComparer<'T> -> int
override this.BinarySearch : 'T * System.Collections.Generic.IComparer<'T> -> int
member this.BinarySearch : 'T * System.Collections.Generic.IComparer<'T> -> int
Public Function BinarySearch (item As T, comparer As IComparer(Of T)) As Integer

參數

item
T

要尋找的物件。 這個參考類型的值可以是 Null。

comparer
IComparer<T>

比較項目時要使用的實作,或適用於預設比較子的 null

傳回

如果找到項目,則為 ImmutableList<T>.Builder 中項目以零為起始的索引,否則為負數,此負數是大於 item 之下一個項目索引的位元補數。

例外狀況

comparernull,且預設比較子 Default 找不到 IComparable<T> 泛型介面實作或類型 T 的 IComparable 介面。

備註

ImmutableList<T>.Builder如果 不包含指定的值,則方法會傳回負整數。 您可以將位補碼運算 (~) 套用至這個負整數,以取得大於搜尋值的第一個專案索引。 將值插入 至 ImmutableList<T>.Builder時,這個索引應該當做插入點使用,以維護排序順序。

適用於

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

來源:
ImmutableList_1.Builder.cs
來源:
ImmutableList_1.Builder.cs
來源:
ImmutableList_1.Builder.cs

使用指定的比較子來搜尋項目之指定範圍的 ImmutableList<T>.Builder,並傳回項目以零為起始的索引。

public:
 virtual int BinarySearch(int index, int count, T item, System::Collections::Generic::IComparer<T> ^ comparer);
public:
 int BinarySearch(int index, int count, T item, System::Collections::Generic::IComparer<T> ^ comparer);
public int BinarySearch (int index, int count, T item, System.Collections.Generic.IComparer<T> comparer);
public int BinarySearch (int index, int count, T item, System.Collections.Generic.IComparer<T>? comparer);
abstract member BinarySearch : int * int * 'T * System.Collections.Generic.IComparer<'T> -> int
override this.BinarySearch : int * int * 'T * System.Collections.Generic.IComparer<'T> -> int
member this.BinarySearch : int * int * 'T * System.Collections.Generic.IComparer<'T> -> int
Public Function BinarySearch (index As Integer, count As Integer, item As T, comparer As IComparer(Of T)) As Integer

參數

index
Int32

要搜尋範圍內之以零為起始的起始索引。

count
Int32

搜尋範圍的長度。

item
T

要尋找的物件。 這個參考類型的值可以是 Null。

comparer
IComparer<T>

比較項目時要使用的實作,或適用於預設比較子的 null

傳回

如果找到項目,則為 ImmutableList<T>.Builder 中項目以零為起始的索引,否則為負數,此負數是大於 item 之下一個項目索引的位元補數。

例外狀況

index 小於 0。 -或-

count 小於 0。

indexcount 不代表 List<T> 中的有效範圍。

comparernull,且預設比較子 Default 找不到 IComparable<T> 泛型介面實作或類型 T 的 IComparable 介面。

備註

ImmutableList<T>.Builder如果 不包含指定的值,則方法會傳回負整數。 您可以將位補碼運算 (~) 套用至這個負整數,以取得大於搜尋值的第一個專案索引。 將值插入 至 ImmutableList<T>.Builder時,這個索引應該當做插入點使用,以維護排序順序。

適用於