ImmutableArray.BinarySearch Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
BinarySearch<T>(ImmutableArray<T>, T) |
Searches the sorted immutable array for a specified element using the default comparer and returns the zero-based index of the element, if it's found. |
BinarySearch<T>(ImmutableArray<T>, T, IComparer<T>) |
Searches a sorted immutable array for a specified element and returns the zero-based index of the element, if it's found. |
BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T) |
Searches a sorted immutable array for a specified element and returns the zero-based index of the element, if it's found. |
BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T, IComparer<T>) |
Searches a sorted immutable array for a specified element and returns the zero-based index of the element. |
BinarySearch<T>(ImmutableArray<T>, T)
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
Searches the sorted immutable array for a specified element using the default comparer and returns the zero-based index of the element, if it's found.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, T value);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, T value);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * 'T -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), value As T) As Integer
Type Parameters
- T
The type of element stored in the array.
Parameters
- array
- ImmutableArray<T>
The sorted array to search.
- value
- T
The object to search for.
Returns
The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than value
or, if there is no larger element, the bitwise complement of Count.
Exceptions
value
does not implement IComparable or the search encounters an element that does not implement IComparable.
Applies to
BinarySearch<T>(ImmutableArray<T>, T, IComparer<T>)
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
Searches a sorted immutable array for a specified element and returns the zero-based index of the element, if it's found.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, T value, System::Collections::Generic::IComparer<T> ^ comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, T value, System.Collections.Generic.IComparer<T> comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, T value, System.Collections.Generic.IComparer<T>? comparer);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * 'T * System.Collections.Generic.IComparer<'T> -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), value As T, comparer As IComparer(Of T)) As Integer
Type Parameters
- T
The type of element stored in the array.
Parameters
- array
- ImmutableArray<T>
The sorted array to search.
- value
- T
The object to search for.
- comparer
- IComparer<T>
The comparer implementation to use when comparing elements, or null to use the default comparer.
Returns
The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than value
or, if there is no larger element, the bitwise complement of Count.
Exceptions
comparer
is null and value
does not implement IComparable or the search encounters an element that does not implement IComparable.
Applies to
BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T)
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
Searches a sorted immutable array for a specified element and returns the zero-based index of the element, if it's found.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, int index, int length, T value);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, int index, int length, T value);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * int * int * 'T -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), index As Integer, length As Integer, value As T) As Integer
Type Parameters
- T
The type of element stored in the array.
Parameters
- array
- ImmutableArray<T>
The sorted array to search.
- index
- Int32
The starting index of the range to search.
- length
- Int32
The length of the range to search.
- value
- T
The object to search for.
Returns
The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than value
or, if there is no larger element, the bitwise complement of Count.
Exceptions
value
does not implement IComparable or the search encounters an element that does not implement IComparable.
index
and length
do not specify a valid range in array
.
index
is less than the lower bound of array
.
-or-
length
is less than zero.
Applies to
BinarySearch<T>(ImmutableArray<T>, Int32, Int32, T, IComparer<T>)
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
- Source:
- ImmutableArray.cs
Searches a sorted immutable array for a specified element and returns the zero-based index of the element.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static int BinarySearch(System::Collections::Immutable::ImmutableArray<T> array, int index, int length, T value, System::Collections::Generic::IComparer<T> ^ comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, int index, int length, T value, System.Collections.Generic.IComparer<T> comparer);
public static int BinarySearch<T> (this System.Collections.Immutable.ImmutableArray<T> array, int index, int length, T value, System.Collections.Generic.IComparer<T>? comparer);
static member BinarySearch : System.Collections.Immutable.ImmutableArray<'T> * int * int * 'T * System.Collections.Generic.IComparer<'T> -> int
<Extension()>
Public Function BinarySearch(Of T) (array As ImmutableArray(Of T), index As Integer, length As Integer, value As T, comparer As IComparer(Of T)) As Integer
Type Parameters
- T
The type of element stored in the array.
Parameters
- array
- ImmutableArray<T>
The sorted array to search.
- index
- Int32
The starting index of the range to search.
- length
- Int32
The length of the range to search.
- value
- T
The object to search for.
- comparer
- IComparer<T>
The comparer to use when comparing elements for equality or null
to use the default comparer.
Returns
The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than value
or, if there is no larger element, the bitwise complement of Count.
Exceptions
comparer
is null and value
does not implement IComparable or the search encounters an element that does not implement IComparable.
index
and length
do not specify a valid range in array
.
-or-
comparer
is null
, and value
is of a type that is not compatible with the elements of array
.
index
is less than the lower bound of array
.
-or-
length
is less than zero.
Applies to
.NET