IArrayList.LastIndexOf

Syntax

LastIndexOf(Value: Variant): Integer;

Parameters

Value. Value that should be found.

Description

The LastIndexOf method reversely searches for value and returns index of the first found element in case of successful search, otherwise it returns -1.

Comments

The method returns element index in case of successful search, and -1 if the value is not found.

Example

Sub UserProc;
Var
    ArrayL: IArrayList;
    i: Integer;
Begin
    ArrayL := New ArrayList.Create;
    For i := 0 To Math.RandBetweenI(50100Do
        ArrayL.Add(Math.RandBetweenI(0100));
    End For;
    i := ArrayL.LastIndexOf(25);
End Sub UserProc;

After executing the example a dynamic array of random integer numbers is created, and reverse search of the 25 value is executed. The "i" variable contains the number of the first found element in case of successful search.

See also:

IArrayList