System.Generics.Collections.TList.IndexOf

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function IndexOf(const Value: T): NativeInt; inline;

C++

System::NativeInt __fastcall IndexOf(const T Value);

Properties

Type Visibility Source Unit Parent
function public
System.Generics.Collections.pas
System.Generics.Collections.hpp
System.Generics.Collections TList

Description

Searches for an element using linear search.

IndexOf searches for the list element Value using a linear search. The method returns the zero-based index of the first entry equal to Value. If not found, it returns -1.

Since the search is linear, it is an O(n) operation for a list with n entries. The BinarySearch method is usually faster, but requires a sorted list.

See Also

Code Examples