BinarySearch()

System::MemoryExtensions::BinarySearch(const ReadOnlySpan<T>&, const TComparable&) function

Performs binary search on a sorted span.

template<typename T,typename TComparable> int32_t System::MemoryExtensions::BinarySearch(const ReadOnlySpan<T> &span, const TComparable &comparable)

Template parameters

ParameterDescription
TThe type of elements in the span
TComparableThe type of the comparable value

Arguments

ParameterTypeDescription
spanconst ReadOnlySpan<T>&The sorted span to search
comparableconst TComparable&The value to search for

Return Value

Index of the found element, or bitwise complement of the insertion point if not found

System::MemoryExtensions::BinarySearch(const ReadOnlySpan<T>&, const T&, const SharedPtr<TComparer>&) function

Performs binary search on a sorted span using a custom comparer.

template<typename T,typename TComparer> int32_t System::MemoryExtensions::BinarySearch(const ReadOnlySpan<T> &span, const T &value, const SharedPtr<TComparer> &comparerPtr)

Template parameters

ParameterDescription
TThe type of elements in the span
TComparerThe type of the comparer

Arguments

ParameterTypeDescription
spanconst ReadOnlySpan<T>&The sorted span to search
valueconst T&The value to search for
comparerPtrconst SharedPtr<TComparer>&The comparer to use for comparisons

Return Value

Index of the found element, or bitwise complement of the insertion point if not found

System::MemoryExtensions::BinarySearch(const Span<T>&, const TComparable&) function

Performs binary search on a mutable sorted span.

template<typename T,typename TComparable> int32_t System::MemoryExtensions::BinarySearch(const Span<T> &span, const TComparable &comparable)

Template parameters

ParameterDescription
TThe type of elements in the span
TComparableThe type of the comparable value

Arguments

ParameterTypeDescription
spanconst Span<T>&The sorted span to search
comparableconst TComparable&The value to search for

Return Value

Index of the found element, or bitwise complement of the insertion point if not found

System::MemoryExtensions::BinarySearch(const Span<T>&, const T&, const SharedPtr<TComparer>&) function

Performs binary search on a mutable sorted span using a custom comparer.

template<typename T,typename TComparer> int32_t System::MemoryExtensions::BinarySearch(const Span<T> &span, const T &value, const SharedPtr<TComparer> &comparer)

Template parameters

ParameterDescription
TThe type of elements in the span
TComparerThe type of the comparer

Arguments

ParameterTypeDescription
spanconst Span<T>&The sorted span to search
valueconst T&The value to search for
comparerconst SharedPtr<TComparer>&The comparer to use for comparisons

Return Value

Index of the found element, or bitwise complement of the insertion point if not found

See Also