CollectionAlgorithms.BinarySearch<TListItem, TMatchItem> Method (IList<TListItem>, TMatchItem, CollectionAlgorithms.ComparisonOfDifferentTypes<TListItem, TMatchItem>, Int32, Int32) |
Uses a binary search algorithm to locate a specific element in the sorted
IList<T>. The element to search for can be a different type from the items
in the collection.
Namespace:
AGI.Foundation.Infrastructure
Assembly:
AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 24.3.420.0 (24.3.420.0)
Syntaxpublic static int BinarySearch<TListItem, TMatchItem>(
IList<TListItem> collection,
TMatchItem item,
CollectionAlgorithms.ComparisonOfDifferentTypes<TListItem, TMatchItem> comparer,
int startIndex,
int length
)
Public Shared Function BinarySearch(Of TListItem, TMatchItem) (
collection As IList(Of TListItem),
item As TMatchItem,
comparer As CollectionAlgorithms.ComparisonOfDifferentTypes(Of TListItem, TMatchItem),
startIndex As Integer,
length As Integer
) As Integer
public:
generic<typename TListItem, typename TMatchItem>
static int BinarySearch(
IList<TListItem>^ collection,
TMatchItem item,
CollectionAlgorithms.ComparisonOfDifferentTypes<TListItem, TMatchItem>^ comparer,
int startIndex,
int length
)
static member BinarySearch :
collection : IList<'TListItem> *
item : 'TMatchItem *
comparer : CollectionAlgorithms.ComparisonOfDifferentTypes<'TListItem, 'TMatchItem> *
startIndex : int *
length : int -> int
Parameters
- collection
- Type: System.Collections.Generic.IList<TListItem>
The collection to search. - item
- Type: TMatchItem
The item to find. - comparer
- Type: AGI.Foundation.Infrastructure.CollectionAlgorithms.ComparisonOfDifferentTypes<TListItem, TMatchItem>
The comparison to use to compare items in the collection to the item to search for. - startIndex
- Type: System.Int32
The index of the first item to consider in the search. - length
- Type: System.Int32
The number of items to consider in the search, starting with startIndex.
Type Parameters
- TListItem
- The type of item in the collection.
- TMatchItem
- The type of item to search for.
Return Value
Type:
Int32
The zero-based index of item in the sorted IList, if
item is found; otherwise, a negative number
that is the bitwise complement of the index of the next element that is larger than
item or, if there is no larger element, the bitwise complement of
Count.
Remarks
See Also