System.Classes.TStrings.SetCapacity

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure SetCapacity(NewCapacity: Integer); virtual;

C++

virtual void __fastcall SetCapacity(int NewCapacity);

Properties

Type Visibility Source Unit Parent
procedure
function
protected
System.Classes.pas
System.Classes.hpp
System.Classes TStrings

Description

Changes the amount of memory allocated to hold strings in the list.

SetCapacity is the protected write implementation of the Capacity property.

NewCapacity is the number of strings the list can hold after the capacity has changed.

In TStrings, the SetCapacity method does nothing. Descendent classes must override this method to change the number of strings that the list can hold.

Note: For descendent classes that implement SetCapacity, assigning a value smaller than Count removes strings from the end of the list. Assigning a value greater than Count allocates space for more strings to be added.

See Also