IArrayList.IndexOfPos

Syntax

IndexOfPos(Value: Variant; StartIndex: Integer): Integer;

Parameters

Value. Element value that should be found.

StartIndex. Element index, starting from which the search is executed.

Description

The IndexOfPos method executes direct search of value, starting from element with the StartIndex index, and returns element index in case of successful search, otherwise it returns -1.

Example

Sub Main;

Var

ArrayL: IArrayList;

i: Integer;

Begin

ArrayL:=New ArrayList.Create;

For i:=0 To Math.RandBetweenI(50,100) Do

ArrayL.Add(Math.RandBetweenI(0,100));

End For;

i:=ArrayL.IndexOfPos(25,Double.FloorInt(ArrayL.Count/2));

End Sub Main;

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

See also:

IArrayList