TList 使用

TList包含对象指针列表。
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对象。

procedure TForm1.Button1Click(Sender: TObject);

 const
  //黑桃,红桃,方块,草花
  CardType:array[0..3] of String = ('S','H','D','C');
const
  //取出的牌数
  CardNums = 4;
type
  //保存牌的指针信息
  RCardrecord = record
    CardInfo:String[2];
  end;
  PCard = ^RCardrecord;
var
  t_List:TList;
  I:Integer;
  t_Sub,t_Spare:Integer;
  t_CardType,t_CardNum:String;
  p_Card:PCard;
  t_Random:Integer;
  t_CardInfo:String[8];
  Count:Integer;
begin
  //定义一个链表
  t_List:=TList.Create;
  //使用循环将52张牌放入链表中
  for I:=1 to 52 do
  begin
    t_Sub:=I div 14;
    t_Spare:=I mod 14;
    t_CardType:=CardType[t_Sub];
    t_CardNum:=IntToHex(t_Spare,1);
    New(p_Card);
    p_Card.CardInfo:=t_CardType+t_CardNum;
    t_List.Add(p_Card);
  end;
  //使用随机从52张牌中抽取4张牌,并保存在 t_CardInfo中
  Randomize;
  for I:=1 to CardNums do
  begin
    t_Random:=Random(t_List.Count);
    p_Card:=t_List.Items[t_Random];
    t_CardInfo:=t_CardInfo+p_Card^.CardInfo;
    t_List.Delete(t_Random);
    DisPose(p_Card);
  end;
  Canvas.TextOut(10,10,t_CardInfo);
  //清空链表中的指针
  Count:=t_List.Count;
  for I:=Count-1 downto 0 do
  begin
    p_Card:=t_List.Items[I];
    t_List.Delete(I);
    DisPose(p_Card);
  end;
  //释放链表
  t_List.Free;
end;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
参考链接: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、付费专栏及课程。

余额充值