AlgorithmsBinarySearchT Method (IListT, T, IComparerT, Int32) |
Searches a sorted list for an item via binary search. The list must be sorted
by the ordering in the passed instance of IComparer<T>.
Namespace: X3Platform.CollectionsAssembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntaxpublic static int BinarySearch<T>(
IList<T> list,
T item,
IComparer<T> comparer,
out int index
)
public:
generic<typename T>
static int BinarySearch(
IList<T>^ list,
T item,
IComparer<T>^ comparer,
[OutAttribute] int% index
)
Parameters
- list
- Type: System.Collections.GenericIListT
The sorted list to search. - item
- Type: T
The item to search for. - comparer
- Type: System.Collections.GenericIComparerT
The comparer instance used to sort the list. Only
the Compare method is used. - index
- Type: SystemInt32
Returns the first index at which the item can be found. If the return
value is zero, indicating that item was not present in the list, then this
returns the index at which item could be inserted to maintain the sorted
order of the list.
Type Parameters
- T
[Missing <typeparam name="T"/> documentation for "M:X3Platform.Collections.Algorithms.BinarySearch``1(System.Collections.Generic.IList{``0},``0,System.Collections.Generic.IComparer{``0},System.Int32@)"]
Return Value
Type:
Int32
The number of items equal to
item that appear in the list.
See Also