Method BinarySearch
- Namespace
- Gamelogic.Extensions.Algorithms
- Assembly
- Gamelogic.Extensions.dll
BinarySearch<TCollection, TElement>(ICollection<TCollection>, TElement, Func<TCollection, TElement>)
Find an element in a collection by binary searching. This requires the collection to be sorted on the values returned by getSubElement This will compare some derived property of the elements in the collection, rather than the elements themselves.
public static int BinarySearch<TCollection, TElement>(this ICollection<TCollection> source, TElement value, Func<TCollection, TElement> getSubElement)
Parameters
sourceICollection<TCollection>valueTElementgetSubElementFunc<TCollection, TElement>
Returns
Type Parameters
TCollectionTElement
BinarySearch<TCollection, TElement>(ICollection<TCollection>, TElement, Func<TCollection, TElement>, IComparer<TElement>)
Find an element in a collection by binary searching. This requires the collection to be sorted on the values returned by getSubElement This will compare some derived property of the elements in the collection, rather than the elements themselves.
public static int BinarySearch<TCollection, TElement>(this ICollection<TCollection> source, TElement value, Func<TCollection, TElement> getSubElement, IComparer<TElement> comparer)
Parameters
sourceICollection<TCollection>valueTElementgetSubElementFunc<TCollection, TElement>comparerIComparer<TElement>
Returns
Type Parameters
TCollectionTElement
BinarySearch<TCollection, TElement>(ICollection<TCollection>, TElement, Func<TCollection, TElement>, int, int)
Find an element in a collection by binary searching. This requires the collection to be sorted on the values returned by getSubElement This will compare some derived property of the elements in the collection, rather than the elements themselves.
public static int BinarySearch<TCollection, TElement>(this ICollection<TCollection> source, TElement value, Func<TCollection, TElement> getSubElement, int index, int length)
Parameters
sourceICollection<TCollection>valueTElementgetSubElementFunc<TCollection, TElement>indexintlengthint
Returns
Type Parameters
TCollectionTElement
BinarySearch<TCollection, TElement>(ICollection<TCollection>, TElement, Func<TCollection, TElement>, int, int, IComparer<TElement>)
Find an element in a collection by binary searching. This requires the collection to be sorted on the values returned by getSubElement This will compare some derived property of the elements in the collection, rather than the elements themselves.
public static int BinarySearch<TCollection, TElement>(this ICollection<TCollection> source, TElement value, Func<TCollection, TElement> getSubElement, int index, int length, IComparer<TElement> comparer)
Parameters
sourceICollection<TCollection>valueTElementgetSubElementFunc<TCollection, TElement>indexintlengthintcomparerIComparer<TElement>
Returns
Type Parameters
TCollectionTElement