TList( unit KOL.pas ) ï TObj ï _TObj

TList = object( TObj )

Simple list of pointers. It is used in KOL instead of standard VCL TList to store any kind data (or pointers to these ones). Can be created calling function NewList.

### TList properties

property Count: Integer;
Returns count of items in the list. It is possible to delete a number of items at the end of the list, keeping only first Count items alive, assigning new value to Count property (less then Count it is).

property Capacity: Integer;
Returns number of pointers which could be stored in the list without reallocating of memory. It is possible change this value for optimize usage of the list (for minimize number of reallocating memory operations).

property Items[ Idx: Integer ]: Pointer; default;
Provides access (read and write) to items of the list. Please note, that TList is not responsible for freeing memory, referenced by stored pointers.

property AddBy: Integer;
Value to increment capacity when new items are added or inserted and capacity need to be increased.

property DataMemory: PPointerList; Ñ
Raw data memory. Can be used for direct access to items of a list. Do not use it for TLIST_FAST !

#### Properties, inherited from TObj

### TList methods

destructor Destroy; virtual; N
Destroys list, freeing memory, allocated for pointers. Programmer is resposible for destroying of data, referenced by the pointers.

procedure Clear;
Makes Count equal to 0. Not responsible for freeing (or destroying) data, referenced by released pointers.

procedure Add( Value: Pointer );
Adds pointer to the end of list, increasing Count by one.

procedure Insert( Idx: Integer; Value: Pointer );
Inserts pointer before given item. Returns Idx, i.e. index of inserted item in the list. Indeces of items, located after insertion point, are increasing. To add item to the end of list, pass Count as index parameter. To insert item before first item, pass 0 there.

function IndexOf( Value: Pointer ): Integer;
Searches first (from start) item pointer with given value and returns its index (zero-based) if found. If not found, returns -1.

procedure Delete( Idx: Integer );
Deletes given (by index) pointer item from the list, shifting all follow item indeces up by one.

procedure DeleteRange( Idx, Len: Integer );
Deletes Len items starting from Idx.

procedure Remove( Value: Pointer );
Removes first entry of a Value in the list.

function Last: Pointer;
Returns the last item (or nil, if the list is empty).

procedure Swap( Idx1, Idx2: Integer );
Swaps two items in list directly (fast, but without testing of index bounds).

procedure MoveItem( OldIdx, NewIdx: Integer );
Moves item to new position. Pass NewIdx >= Count to move item after the last one.

procedure Release;
Especially for lists of pointers to dynamically allocated memory. Releases all pointed memory blocks and destroys object itself.

procedure ReleaseObjects;
Especially for a list of objects derived from TObj. Calls Free for every of the object in the list, and then calls Free for the object itself.

procedure Assign( SrcList: PList );
Copies all source list items.

procedure AddItems( const AItems: array of Pointer );
Adds a list of items given by a dynamic array.

function ItemAddress( Idx: Integer ): Pointer;
Returns an address of memory occupying by the item with index Idx. (If the item is a pointer, returned value is a pointer to a pointer). Item with index requested must exist.

#### Methods, inherited from TObj

### TList events

#### Events, inherited from TObj

### TList fields

#### Fields, inherited from TObj

[ Index ]

This help is generated 14-Jun-2010 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov
Modified (C) 2003 by Alexander Bartov