TSubstringList.Delete Method

procedure Delete(const Index: Integer);

Deletes item Index; the later items move down by one.

#NameDescription
1Index

The item's index, 0..Count - 1.

Result: stored in self (calling object)

Remarks:

Only the items' order changes: no text moves, and the deleted item's place is taken by the next add. With OwnsObjects its object is freed. A view of the deleted item - in a local, or stored in another item by List[j] := List[i] - dangles from then on, as designed, as a Substring view of a freed string does. An Index outside the list raises EStringListError.

Examples

Deleting an item.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('a');
        List.Add('b');
        List.Delete(0);
        Assert(List.Count = 1);
        Assert(List[0] = 'b');
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.DeleteRange, TSubstringList.Remove, TSubstringList.Clear