TSubstringList.Capacity Property

property Capacity: Integer read FCapacity write SetCapacity;

The number of items the list holds without growing: a multiple of 128, at least 128.

Returns: Integer

Remarks:

Setting it is a reservation without content, as Substring.Capacity is: the list is empty afterwards, every item given up as Clear gives it up, and it holds Value items rounded up to a multiple of 128. Resize keeps the items. Below 0 it raises EStringListError.

Examples

A reservation, then the items.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(1);
    try
        List.Add('a');
        List.Capacity := 2;
        Assert(List.Count = 0);
        List.Add('b');
        List.Add('c');
        Assert(List[0] = 'b');
        Assert(List[1] = 'c');
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.Resize