Click or drag to resize

CollectionAlgorithmsBinarySearchTListItem, TMatchItem Method (IListTListItem, TMatchItem, CollectionAlgorithmsComparisonOfDifferentTypesTListItem, TMatchItem)

Uses a binary search algorithm to locate a specific element in the sorted IListT. 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: 19.2.399.0 (19.2.399.0)
public static int BinarySearch<TListItem, TMatchItem>(
	IList<TListItem> collection,
	TMatchItem item,
	CollectionAlgorithmsComparisonOfDifferentTypes<TListItem, TMatchItem> comparer


Type: System.Collections.GenericIListTListItem
The collection to search.
Type: TMatchItem
The item to find.
Type: AGI.Foundation.InfrastructureCollectionAlgorithmsComparisonOfDifferentTypesTListItem, TMatchItem
The comparison to use to compare items in the collection to the item to search for.

Type Parameters

The type of item in the collection.
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.
See Also