数组集合之TList

Tlist 繼承於 : TObject .

 用来存储指针的数组的类.

屬性:

1.  property Capacity: Integer;  

  容量, 理論分配空間; 每次分配 4 個 , 自動擴容.

 

2. property Count: Integer;  

  計數, 實際佔用的空間.

 

3. Items[Index: Integer]: Pointer; default;

項目數值.

默認值, 即 TList[i] 與 TList.Items[i] 是等效的.

 

4. property List: PPointerList;

指向每一個項目的指針數值;

與 TList[i] , TList.Items[i] 是等效的.

 

方法:

1. function Add(Item: Pointer): Integer;

在Items項目後增加一項.

 

2. procedure Assign(ListA: TList; AOperator: TListAssignOp = laCopy; ListB: TList = nil);

將對象指針指向另一個 TList 類型的實例. 簡單用法: myList2.Assign(myList);

 

3. procedure Clear; virtual;

清除所有Item. Count = 0;

 

4. procedure Delete(Index: Integer);

刪除指定的 Item.

 

5. procedure Exchange(Index1, Index2: Integer);

交換 Item.

 

6. function Extract(Item: Pointer): Pointer;

從 Items 刪除與指定內容相同的所有 Item.

 

7. function First: Pointer;

返回 Items[0].

 

8. function IndexOf(Item: Pointer): Integer;

檢索 Index , 例子:

if MyList.IndexOf(MyObject)=-1 then MyList.Add(MyObject);

 

9. procedure Insert(Index: Integer; Item: Pointer);

指定位置插入一個 Item.

 

10. function Last: Pointer;

返回 Items[Count - 1].

 

11. procedure Move(CurIndex, NewIndex: Integer);

把Item 的位置從 CurIndex 移到 NewIndex.

 

12. procedure Pack;

刪除 所有為nil 的Item .

 

13. function Remove(Item: Pointer): Integer;

刪除和指定的 Item 第一個相同的 Item . 不清楚所要刪除的Item的 Index 時使用.

返回值為要刪除的 Item 的 Index . 若返回 -1 , 則沒有找到.

注意 與 Extract 的區別.

 

14. procedure Sort(Compare: TListSortCompare);

使用CompareText方法, 執行QuickSort . 使用示例:

 

function CompareNames(Item1, Item2: Pointer): Integer;
begin
  Result := CompareText((Item1 as TComponent).Name, (Item2 as TComponent).Name);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  List1.Sort(@CompareText);
end;

 

 

應用代碼:

 

 

 

 

 

参考链接: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、付费专栏及课程。

余额充值