ISortedList.IndexOfKey

Syntax

IndexOfKey(Key: Variant): Integer;

Parameters

Key - key of the element, which index should be obtained.

Description

The IndexOfKey method returns element index with the Key key. It returns -1 if element with the Key key does not exist.

Example

Sub Main;

Var

SortList: ISortedList;

i: Integer;

Begin

SortList:=New SortedList.Create;

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

SortList.Add("Key_"+Math.RandBetweenI(0,100).ToString,"Number "+Math.RandBetweenI(0,100).ToString);

End For;

i:=SortList.IndexOfKey("Key_25");

End Sub Main;

After executing the example the "i" variable contains element index with the Key_25 key if it exists.

See also:

ISortedList