Performs a binary search using IComparable. 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 IComparable implementation before this method is calling, the result is not guaranteed. The value passed in must implement IComparable, unless it is null. The IComparable.CompareTo method will be called on the value passed in, with the values in the queue as parameters, rather than the other way round. No test is made to make sure that the types of item are the same - it is up to the implementation of IComparable to throw an exception if incomparable types are presented. A null reference is treated as being less than any item, (so passing in null will always return 0 or -1). The implementation of IComparable is never asked to compare to null.

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
)
Visual Basic
Public Function BinarySearch ( 
	obj As T
) As Integer
Visual C++
public:
int BinarySearch(
	T obj
)
F#
member BinarySearch : 
        obj : 'T -> int 

Parameters

obj
Type: T
The item to search for

Return Value

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

See Also