Chili.Opf3 Send comments on this topic.
BinarySearch(Int32,Int32,T,Generic IComparer) Method
See Also 
Chili.Opf3 Namespace > Generic ObjectSet Class > BinarySearch Method : BinarySearch(Int32,Int32,T,Generic IComparer) Method




index
The zero-based starting index of the range to search.
count
The length of the range to search.
item
The object to locate. The value can be null for reference types.
comparer
The cComparer implementation to use when comparing elements or null to use the default comparer.
Searches a range of elements in the sorted ObjectSet for an element using the specified comparer and returns the zero-based index of the element.

Syntax

Visual Basic (Declaration) 
Overloads Public Function BinarySearch( _
   ByVal index As Integer, _
   ByVal count As Integer, _
   ByVal item As T, _
   ByVal comparer As IComparer(Of T) _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As ObjectSet(Of T)
Dim index As Integer
Dim count As Integer
Dim item As T
Dim comparer As IComparer(Of T)
Dim value As Integer
 
value = instance.BinarySearch(index, count, item, comparer)
C# 
public int BinarySearch( 
   int index,
   int count,
   T item,
   IComparer<T> comparer
)
Managed Extensions for C++ 
public: int BinarySearch( 
   int index,
   int count,
   T item,
   IComparer<T>* comparer
) 
C++/CLI 
public:
int BinarySearch( 
   int index,
   int count,
   T item,
   IComparer<T>^ comparer
) 

Parameters

index
The zero-based starting index of the range to search.
count
The length of the range to search.
item
The object to locate. The value can be null for reference types.
comparer
The cComparer implementation to use when comparing elements or null to use the default comparer.

Return Value

The zero-based index of item in the sorted ObjectSet, if item is found; otherwise, a negative number, which is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.

Exceptions

ExceptionDescription
InvalidOperationExceptionThe default comparer cannot find an IComparable implementation of the Type T.
ArgumentOutOfRangeExceptionIndex is less than zero or Count is less then zero.
ArgumentExceptionIndex and count do not denote a valid range in the ObjectSet.

Requirements

Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family

See Also