zoukankan      html  css  js  c++  java
  • [原创]Delphi XE 泛型 容器[1] Tlist<T>使用

    {该文首发于博客园 滔Roy,无须授权即可转发,请自觉保留头部申明}

    Delphi XE 泛型 容器[1] Tlist<T>

    uses
      System.Generics.Collections;  //泛型容器单元
    

    包含了以下类( 来自 XE10 ):

    • TArray
    • TEnumerator<T>
    • TEnumerable<T>
    • TList<T>
    • TThreadList<T>
    • TQueue<T>
    • TStack<T>
    • TDictionary<TKey,TValue>
    • TObjectList<T>
    • TObjectQueue<T>
    • TThreadedQueue<T>

    使用示例:

    type
      TSClient = class(TObject)          //TObject 是 System 单元中定义的第一个类。
        IP,Name        : String;
        Listk    : Integer;
      end;
    
    var
      f_Lists:TList<TSClient>;      //定义泛型变量

    //创建

    f_Lists:=TList<TSClient>.Create;
    

    //添加

    var
      fClient:TSClient;
    begin
      fClient:=TSClient.Create;
      fClient.IP:=Edit1.Text;
      fClient.Name:=Edit2.Text;
      fClient.Listk:=99;
      f_Lists.Add(flist); //添加 
    end;

    //定位数据

    fClient:=f_lists.Items[i];
    Label1.Text:=fClient.Name +'  '+ fClient.IP + '  '+ fClient.Listk.ToString;

    //删除

    f_Lists.Delete(i);
    

    创建时间:2020.06.08  更新时间:

  • 相关阅读:
    js_sl 分享
    js_sl 延迟菜单
    jszs 历史管理
    jszs 对象引用
    jszs 快速排序
    jszs 枚举算法
    dom cookie记录用户名
    dom 拖拽回放
    dom div重合提示
    dom 输入文字模拟滚动
  • 原文地址:https://www.cnblogs.com/guorongtao/p/13066721.html
Copyright © 2011-2022 走看看