System.Generics.Collections.TArray.IndexOf
Delphi
class function IndexOf<T>(const Values: array of T; const Item: T): NativeInt; overload; static;
class function IndexOf<T>(const Values: array of T; const Item: T;
Index: NativeInt): NativeInt; overload; static;
class function IndexOf<T>(const Values: array of T; const Item: T;
const Comparer: IComparer<T>; Index, Count: NativeInt): NativeInt; overload; static;
C++
template<typename T> static System::NativeInt __fastcall IndexOf(const T *Values, const System::NativeInt Values_High, const T Item)/* overload */;
template<typename T> static System::NativeInt __fastcall IndexOf(const T *Values, const System::NativeInt Values_High, const T Item, System::NativeInt Index)/* overload */;
template<typename T> static System::NativeInt __fastcall IndexOf(const T *Values, const System::NativeInt Values_High, const T Item, const System::DelphiInterface<System::Generics::Defaults::IComparer__1<T> > Comparer, System::NativeInt Index, System::NativeInt Count)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Generics.Collections.pas System.Generics.Collections.hpp |
System.Generics.Collections | TArray |
Description
Searches for the array element Value
using a linear search. The method returns the zero-based index of the first entry equal to Value
. If it is not found, it returns -1
.
Since the search is linear, it is an O(n) operation for an array with n entries.