Performs a binary search using the specified IComparer. If the value occurs multiple times, there is no guarantee as to which index will be returned. If the value does not occur at all, the bitwise complement of the first index containing a larger value is returned (or the bitwise complement of the size of the queue if the value is larger than any value in the queue). This is the location at which the value should be inserted to preserve sort order. If the list is not sorted according to the appropriate IComparer implementation before this method is calling, the result is not guaranteed. The CompareTo method will be called on the comparer passed in, with the specified value as the first parameter, and values in the queue as the second parameter, rather than the other way round. While a null reference should be treated as being less than any object in most implementations of IComparer, this is not required by this method. Any null references (whether in the queue or the specified value itself) are passed directly to the CompareTo method. This allow for IComparers to reverse the usual order, if required.

Namespace: MonoSoftware.Core.Collections
Assembly: MonoSoftware.Core (in MonoSoftware.Core.dll) Version: 1.0.40.669 (1.0.40.669)

Syntax

C#
public int BinarySearch(
	T obj,
	IComparer<T> comparer
)
Visual Basic
Public Function BinarySearch ( 
	obj As T,
	comparer As IComparer(Of T)
) As Integer
Visual C++
public:
int BinarySearch(
	T obj, 
	IComparer<T>^ comparer
)
F#
member BinarySearch : 
        obj : 'T * 
        comparer : IComparer<'T> -> int 

Parameters

obj
Type: T
The object to search for
comparer
Type: System.Collections.Generic..::..IComparer<(Of <(<'T>)>)>
The comparator to use for searching. Must not be null.

Return Value

Type: Int32
A location in the queue containing the object, or the bitwise complement of the first index containing a larger value.

See Also