TArrayList
TList<TElement>
that stores its elements in a contiguous array.Inheritance
Level | Ancestor | Description |
---|---|---|
1 | TObject | Ultimate ancestor in a class hierarchy |
2 | TBaseObject | A base class for objects that can be used instead of TObject . |
3 | TCollection<TElement> | Abstract base class for collections that store elements of type TElement |
4 | TList<TElement> | A collection of elements that can be accessed by index. |
5 | TArrayList |
Source
Collection.List.Array_.pas (29)
Description
Because TArrayList<TElement>
stores its elements in a contiguous array, lookup operations
by index are very fast. This comes at the expense of the lower performance of insert and delete operations
because those operations can force the array to be moved to another memory location to accommodate size
changes. TArrayList<TElement>
tries to minimize the amount relocations of the array
by maintaining some slack in the array size: the array size is available as Capacity
and is always >= Count
. When it is known in advance that a large number of elements will
be added to the list it is advisable to set an appropriate Capacity
in advance in order
to limit or avoid memory relocations.
Fields
Scope | Visibility | Type | Name | Description |
---|---|---|---|---|
Instance | private | TComparator<TElement> | FComparator | |
Instance | private | array of TElement | FElements | |
Instance | private | TInteger32 | FCount |
Methods
Scope | Visibility | Result | Name | Description |
---|---|---|---|---|
Instance | private | RescaleCapacity() | ||
Instance | protected | TElement | GetElements(Index: TInteger32) | |
Instance | protected | SetElements(Index: TInteger32; Value: TElement) | ||
Instance | protected | TInteger32 | GetCount() | |
Instance | protected | SetCount(Value: TInteger32) | ||
Instance | protected | TInteger32 | GetCapacity() | |
Instance | protected | SetCapacity(Value: TInteger32) | ||
Instance | protected | TComparator<TElement> | GetComparator() | |
Instance | protected | SetComparator(Value: TComparator<TElement>) | ||
Instance | public | Destroy() | ||
Instance | public | TBoolean | Add(Element: TElement) | |
Instance | public | AddAt(Index: TInteger32; Element: TElement) | ||
Instance | public | TElement | ExtractAt(Index: TInteger32) | |
Instance | public | ExchangeAt(Index1: TInteger32; Index2: TInteger32) | ||
Instance | public | Clear() |