TList 对像说明

TList 对像说明
2009年08月16日 下午 10:54

TList 对像说明
━━━━━━━━━━━━━━━━━━━━━━━━━━

TList包含对象指针列表。
类关系 TObject
Tlist用于存储和维护对象列表。TList引入属隆和方法以执行以下操作:
(1)在列表中增加或删除对象。
(2)在列表中重排对象。
(3)在列表中定位和获得对象。
(4)在列表中对对象进行排序。
属性列表
Capacity 标识TList对象维护的指针数组的大小。
Count 表明在列表中使用的项的数量。
Items 列出对象的引用。
List 标识组成Items的指针数组。
方法列表
~TList 删除与TList对象有关的内存。
Add 在列表的末尾插入有关的内存。
Clear 从列表中删除所有项。
Delete 删除Index参数标识的项。
Error 产生EListError异常。
Exchange 交换Items数组中两项的位置。
Expand 增加列表的Capacity。
First 返回Items[0]。
IndexOf 返回Items数组中一指针的索引。
Insert 增加一对象至Items数组中。
Last 返回Items[Count-1]。
Move 在Items数组中改变某一项的位置。
Pack 从Items数组中删除所有的零项。
Remove 从Items数组中删除Items参数的第一个引用。
Sort 在列表中执行QuickSort。
TList 创建一个新的TList对象。
详细说明
属性
TList::Capacity
__property int Capacity = {read=FCapacity,write=SetCapacity,nodefault};
   标识TList对象维护的指针数组的大小。
   设置Capacity为列表将要包含的指旬数。当当设置Capacity属性时,如果没有足够的内存扩展列表为它的新的大小,将产生EOutOfMemory异常。
   在没有重新分配内存情况下,读取Capacity可得到列表能包含的对象数。注意不要混淆Capacity和Count属性;Count属性为列表中使用的项的数量。Capacity值总是大于或等于Count值。当Capacity大于Count,通过设定Capacity至Count可以回收未使用的内存。当添加一对象至列表,而此列表已被填充到Capacity时,Capacity属性自动增加。在增加对象之前设置Capacity能减少内存重分配的数量,因此提高了执行效果。例如:
List->Clear();
List->Capacity = Count;
for(int i=0;i<Count;i++) List->add(...);
   在for循环之前分配Capacity保证在随后的每一Add操作不重新分配列表。在调用Add时避免重新分配可以提高执行效果并且保证Add操作不产生异常。
TList:;Count
__property int Count = {read=FCount,write=SetCount,nodefault};
   表明在列表中使用的项的数量。
   读取Count可以确定Items数组中项的数量。增加Count的大小将在Items数组的末尾增加必要的零指针的数量;减小Count的大小将从Items数组的末尾删除必要的零指针的数量。
   注意:Count并不总等同于列表中引用的对象的数量。在Items数组中,某些项将包含零指针。如果要删除零指针并且设置Count为对象引用的项数,则可以调用Pack方法。
TList::Items
__property void* Items[int Index] = {read=Get,write=Put};
   列出对象的引用。
   使用Items可以获得数组中指定对象的指针。Index参数标识对象的索引;第一个对象的索引值为0,第二个对象的索引值为1,以此类推。设置Items可以在指定位置改变引用。使用带有Count属性的Items可以遍历列表中的所有对象。
   应该注意的是,并不是Items数组中所有的项都需包含对象的索引。有些项可能是零指针。如果要删除零掼针并且减小Items数组的大小至对象的数量,可以调用Pack方法。
TList::List
typedef void* TPointerLIst[134217727];
typedef TPointerLIst* PPointerList;
__property PPointerList List = {read=FList};
   标识组成Items的指针数组。
   使用List直接获得Items数组。
TList::~TList
__fastcall virtual~TList(void);
   删除与TList对象有关的内存。
   在应用中不要直接调用~TList。用delete替代。
   ~TList释放存储项列表的内存。注意,~TList并不释放指向列表元素的内存。
TList::Add
int __fastcall Ad(void* Item);
   在列表的末尾插入新项,可以调用Add方法。Add方法返回值为新项的索引值;列表中第一项的索引值为0
   如果Items数组使用完列表对象Capacity,则Add方法分配更多的内存。Add增加Count值以反映新指针的增加。注意:即使Items数组包含零指针,Add方法总是在Items数组的末尾插入Items指针。
TList::Clear
DYNAMIC void __fastcall Clear(void);
   从列表中删除所有项。
   如果要清空Items数组并且设置Count为0,可以调用Clear方法。Clear方法同时释放用于存储Items数组的内存并且设置Capacity为0。
TList::Delete
void __fastcall Delete(int Index);
   删除Index参数标识的项。
   如果要从列表指定位置删除项,可以调用Delete方法。索引从零开始,因此第一项的索引值为0,第二项的索引值为1,以此类推。调用Delete方法向前移动删除项之后的所有英并减小Count。
   如果要删除一项的索引但并不从列表中删除该项并且改变Count,可设置Index的Items属性为零。注意Delete并不释放的项相关的内存。如果要释放存储删除项的内存,可设置Capacity属性。
TList::Error
virtual void __fastcall Error(const System::AnsiString Msg,int Data)  {Error(__classid(TList),Msg,Data};
   产生EListError异常。
   当TList对象出现错误时,调用Error产生异常。Error组合Msg参数标识的错误消息和Data参数标识的数据植,然后产生EListError异常。调用Error而不是增加一行程序代码,例如:
    throw EListError(MyMsg,iBadValue);
为减少应用程序的代码量。
TList::Exchange
void __fastcall Exchange(int Index1,int Index2);
   交换Items数组中两项的位置。
   如果要交换台Items数组中位于Index1和Index2的项的位置,可以调用Exchange方法。索引从零开始,因此,列表中第一项的索引值为0,第二项的索引值为1,以此类推。
TList::Expand
TList* __fastcall Expand(void);
   增加列表的Capacity。
   为了在列表增加新项,可以调用Expand以创建更多的空间。如果没有填充列表至Capacity,Expand一作任何处理。如果Count = Capacity,Expand按如下增加列表的Capacity。如果Capacity值大于8,Expand增加列表的Capacity至16;如果Capacity值大于4,但是小于8,列表的Capacity增加至8,如果Capacity值小于4,列表的Capacity 增加4。
   返回值为扩展的列表对象。
TList::First
void* __fastcall First(void);
   返回Items[0]。
   调用First获得Items数组中的第一个指针。
TList::IndexOf
int __fastcall IndexOf(void* Item);
TList::Inset
void __fastcall Insert(int Index,void* Item);
   返回Items数组中一指针的索引。
   调用IndexOf获得Items数组中一指针的索引。Item参数标识指针。数组中第一项索引值为0,第二项的索引值为1,以此类推。如果项不在列表中,IndexOf返回-1。如果一指针在列表中出现多次,IndexOf返回第一次出现的索引值。
TList::Last
void* __fastcall(void);
   增加一对象至Items数组中;Index参数标识该对象的添加位置。
   如果要添加Item至Items数组中,可以调用Insert方法。Index参数为基于0的索引,因此,数组中的第一个位置的索引值为0。Insert在指定位置增加项;改变原先处于此位置的项以及后面的所有项。如果必要,Insert扩充列表的Capacity并且设置Items属性。
TList::Move
void __fastcall Move(int CurIndex,int NewIndex);
   返回Items[Count-1]。
   如果要在Items数组中得到最后的指针,可以调用Last方法。
TList::Pack
void __fastcall Pack(void);
   从Items数组中删除所有的零项。
   调用Pack将所有非零项移至Items数组的前面并且减小Count属性为实际使用的项的数量。Pack并不释放存储零指针的内存。为了释放通过Pack方法删除的不使用项所占用的内存,可以设置Capacity属性为Count的新值。
TList::Remove
int __fastcall Remove(void* Item);
   从Items数组中删除Item参数的第一个引用。
   当不知道指定项的索引时,调用Remove从Items数组中删除指定项。在删除指定项之前,返回该项的索引。在指定项删除之后,该项之后的所有项的索引位置提前并且Count减一。应该注意的是,如果Items数组包含指针的多个复制,仅第一个复制被删除。
TList::Sort
typedef int __fastcall (*TListSortCompare)(void* Item1,void* Item2);
void __fastcall Sort(TListSortCompare Compare);
   根据Compare函数的比较,在列表中执行QuickSort。
   如果要对Items数组中草药的项进行排序,可以调用Sort方法。Compare为比较函数,该函数表明项是如何进行排序的。如果Item1小于Item2,则Compare返回值为0;如果Item1大于Item2,则Compare返回值大于0;
TList::TList
__fastcall virtual TList(void);
   创建一个新的TList对象。
   不要直接调用TList。用new替代。

参考链接:https://msdn.microsoft.com/en-us/library/windows/hardware/ff558903%28v=vs.85%29.aspx Parameters tlist Without additional parameters, TList displays all running processes, their process identifiers (PIDs), and the title of the window in which they are running, if any. /p ProcessName Displays the process identifier (PID) of the specified process. ProcessName is the name of the process (with or without file name extension), not a pattern. If the value of ProcessName does not match any running process, TList displays -1. If it matches more than one process name, TList displays only the PID of the first matching process. PID Displays detailed information about the process specified by the PID. For information about the display, see the "Remarks" section below. To find a process ID, type tlist without additional parameter. Pattern Displays detailed information about all processes whose names or window titles match the specified pattern. Pattern can be a complete name or a regular expression. /t Displays a task tree in which each process appears as a child of the process that created it. /c Displays the command line that started each process. /e Displays the session identifier for each process. /k Displays the COM components active in each process. /m Module Lists tasks in which the specified DLL or executable module is loaded. Module can be a complete module name or a module name pattern. /s Displays the services that are active in each process. /v Displays details of running processes including the process ID, session ID, window title, command line, and the services running in the process. 。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值