IArrayList.IndexOfRange

Syntax

IndexOfRange(Value: Variant; StartIndex: Integer; Count: Integer): Integer;

Parameters

Value. Element value that should be found.

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

Count. Number of elements in the range, in which the search is executed.

Description

The IndexOfRange method directly searches for the element in the specified range.

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.IndexOfRange(2510, ArrayL.Count - 20);
End Sub UserProc;

After executing the example a dynamic array of random numbers is generated, and direct search of the 25 value is executed in the whole array, except for the first and last 10 elements. In case of successful search, the "is" variable contains index of the found element.

See also:

IArrayList