SPUtility.BinarySearchWithFallback<T> Method
Performs a binary search of a list for a generic object. If the object is not found in the list, this method finds the zero-based index location in the list at which the generic object should be inserted.
Namespace: Microsoft.SharePoint.Utilities
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Available in SharePoint Online
Syntax
'Declaration
<SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.GenericMethod)> _
Public Shared Function BinarySearchWithFallback(Of T) ( _
lst As IList(Of T), _
t As T, _
comparer As IComparer, _
<OutAttribute> ByRef found As Boolean _
) As Integer
'Usage
Dim lst As IList(Of T)
Dim t As T
Dim comparer As IComparer
Dim found As Boolean
Dim returnValue As Integer
returnValue = SPUtility.BinarySearchWithFallback(lst, _
t, comparer, found)
[SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.GenericMethod)]
public static int BinarySearchWithFallback<T>(
IList<T> lst,
T t,
IComparer comparer,
out bool found
)
Type Parameters
- T
The type of the generic object for which the location is to be found.
Parameters
lst
Type: System.Collections.Generic.IList<T>The list to be searched for the specified generic type.
t
Type: TThe object to be located.
comparer
Type: System.Collections.IComparerThe method implemented by the type to compare two objects.
found
Type: System.Booleantrue indicates that the generic object was found; otherwise false.
Return Value
Type: System.Int32
A 32-bit integer that represents the index location of the object in the list or, if the object was not found, the index location at which the object should be inserted into the list.