LastIndexOfRange(Value: Variant; StartIndex: Integer; Count: Integer): Integer;
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.
The LastIndexOfRange method reversely searches for element in the range and returns index of the first found element in case of successful search, otherwise it returns -1.
The range starts from the element with the StartIndex index and contains Count of elements.
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.LastIndexOfRange(25,10,ArrayL.Count-20);
End Sub Main;
After executing the example a dynamic array of random numbers is generated, and reverse 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 "i" variable contains index of the found element.
See also: