| CollectionExtensionsBinarySearchTCollection, TElement Method (ICollectionTCollection, TElement, FuncTCollection, TElement, Int32, Int32, IComparerTElement) |
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.
Namespace:
Gamelogic.Extensions.Algorithms
Assembly:
Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax 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
- Type: System.Collections.GenericICollectionTCollection
- value
- Type: TElement
- getSubElement
- Type: SystemFuncTCollection, TElement
- index
- Type: SystemInt32
- length
- Type: SystemInt32
- comparer
- Type: System.Collections.GenericIComparerTElement
Type Parameters
- TCollection
- TElement
Return Value
Type:
Int32Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
ICollectionTCollection. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
See Also