Class TTreeMapContainer
Unit
Declaration
type TTreeMapContainer = class(TObject)
Description
An owning, size-sorted list of TTreeMapItem instances.
TTreeMapContainer.Add, TTreeMapContainer.Remove, TTreeMapContainer.RemoveAt and TTreeMapContainer.Clear keep the list sorted by TTreeMapItem.Size in descending order and keep TTreeMapContainer.TotalSize up to date on every mutation. The container owns its items: an item is freed as soon as it is removed, and when the container is cleared or destroyed.
For bulk population use TTreeMapContainer.FastAdd – which skips the duplicate check and does not preserve order – followed by a single TTreeMapContainer.Sort.
Hierarchy
- TObject
- TTreeMapContainer
Overview
Methods
| Public | constructor Create; |
| Public | destructor Destroy; override; |
| Public | function Add(aitem: TTreeMapItem): integer; |
| Public | function Remove(aitem: TTreeMapItem): boolean; |
| Public | function RemoveAt(index: integer): boolean; |
| Public | function IndexOf(aitem: TTreeMapItem): integer; |
| Public | function IndexOfData(adata: pointer): integer; |
| Public | function UpdateSizeAt(index: integer; newsize: int64): boolean; |
| Public | function UpdateSize(aitem: TTreeMapItem; newsize: int64): boolean; |
| Public | procedure Clear; |
| Public | procedure Sort; |
| Public | procedure FastAdd(aitem: TTreeMapItem); |
Properties
| Public | property Count: integer read GetCount; |
| Public | property Items[index: integer]: TTreeMapItem read GetItem; default; |
| Public | property TotalSize: int64 read fTotalSize; |
Description
Methods
| Public | constructor Create; |
|
Creates an empty container. | |
| Public | destructor Destroy; override; |
|
Clears and frees all contained items, then destroys the container. | |
| Public | function Add(aitem: TTreeMapItem): integer; |
|
Adds a single item, preserving descending size order, and updates TTreeMapContainer.TotalSize. Parameters
ReturnsThe index at which the item was inserted. If the item is already present, its existing index is returned; returns | |
| Public | function Remove(aitem: TTreeMapItem): boolean; |
|
Removes and frees an item, located by reference, and updates TTreeMapContainer.TotalSize. Parameters
Returns
| |
| Public | function RemoveAt(index: integer): boolean; |
|
Removes and frees the item at the given index and updates TTreeMapContainer.TotalSize. Parameters
Returns
| |
| Public | function IndexOf(aitem: TTreeMapItem): integer; |
|
Returns the index of an item, located by reference. Parameters
ReturnsThe zero-based index, or | |
| Public | function IndexOfData(adata: pointer): integer; |
|
Returns the index of the first item whose TTreeMapItem.Data pointer equals Parameters
ReturnsThe zero-based index, or | |
| Public | function UpdateSizeAt(index: integer; newsize: int64): boolean; |
|
Changes the size of the item at This is the only supported way to change an item's size, so that the list can stay sorted without a full re-sort. Parameters
Returns
| |
| Public | function UpdateSize(aitem: TTreeMapItem; newsize: int64): boolean; |
|
Convenience wrapper around TTreeMapContainer.UpdateSizeAt that first looks the item up by reference. Parameters
Returns
| |
| Public | procedure Clear; |
|
Removes and frees all items and resets TTreeMapContainer.TotalSize to zero. | |
| Public | procedure Sort; |
|
Sorts the list by TTreeMapItem.Size in descending order. Use together with TTreeMapContainer.FastAdd. | |
| Public | procedure FastAdd(aitem: TTreeMapItem); |
|
Appends an item without checking for duplicates and without preserving sort order, updating TTreeMapContainer.TotalSize. Intended for bulk population; call TTreeMapContainer.Sort once all items have been added. Parameters
| |
Properties
| Public | property Count: integer read GetCount; |
|
The number of items currently in the container. | |
| Public | property Items[index: integer]: TTreeMapItem read GetItem; default; |
|
Indexed, read-only access to the contained items. This is the default property, so | |
| Public | property TotalSize: int64 read fTotalSize; |
|
The sum of the TTreeMapItem.Size values of all contained items. | |
Generated by PasDoc 1.0.4.