Table of Contents

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

source ICollection<TCollection>
value TElement
getSubElement Func<TCollection, TElement>

Returns

int

Type Parameters

TCollection
TElement

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

source ICollection<TCollection>
value TElement
getSubElement Func<TCollection, TElement>
comparer IComparer<TElement>

Returns

int

Type Parameters

TCollection
TElement

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

source ICollection<TCollection>
value TElement
getSubElement Func<TCollection, TElement>
index int
length int

Returns

int

Type Parameters

TCollection
TElement

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

source ICollection<TCollection>
value TElement
getSubElement Func<TCollection, TElement>
index int
length int
comparer IComparer<TElement>

Returns

int

Type Parameters

TCollection
TElement