Introduction to Container class in Delphi2009:
1.TList class:
A container class that can store pointers provides a set of methods and properties to add, delete, rearrange, locate, access, and sort the classes in the container, which is a container based on an array mechanism that compares similar to vectors in C + + and Java in arraylist,tlist Often used to save a list of objects, an array-based mechanism makes it very fast to use subscripts to access objects in the container, but as the objects in the container increase, the speed of insertions and deletions is plummeting, so it is not appropriate to add and remove objects frequently.
Property |
Describe |
Count:integer; |
Returns the number of items in a list |
Items[index:integer]: pointer; Default |
Direct access to items in a list by subscript 0 Index |
Method |
Type |
Describe |
ADD (item:pointer): Integer; |
Function |
Use to add pointers to the list |
Clear; |
Process |
Empty items in a list |
Delete (Index:integer); |
Process |
Delete items in a list that correspond to an index |
IndexOf (item:pointer): Integer; |
Function |
Returns the index of the pointer in the list |
Insert (Index:integer; Item:pointer); |
Process |
Inserts an item into the list at the specified location |
Remove (item:pointer): Integer; |
Function |
Remove a pointer from the list |
Name |
Type |
Describe |
Capacity:integer; |
Property |
Can be used to get or set the number of pointers that a list can hold |
Extract (Item:pointer): pointer; |
function |
Extract is similar to remove to delete a pointer from a list, but to return a pointer that is deleted. |
Exchange (Index1, Index2:integer); |
Procedure |
Two pointers in the swap list |
First:pointer; |
function |
Returns the first pointer in a linked list |
Last:pointer; |
function |
Returns the last pointer in a linked list |
Move (Curindex Newindex:integer); |
Procedure |
Move the pointer from the current position to the new location |
Pack; |
Procedure |
Remove all nil pointers from the list |
Sort (Compare:tlistsortcompare); |
Procedure |
Used to sort items in a linked list, you can set compare parameters for user-defined sort functions |