zoukankan      html  css  js  c++  java
  • 详测 Generics Collections TList (3): Insert、Delete、Remove、Extract

    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses Generics.Collections;
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      List: TList<Integer>;
      i: Integer;
      str: string;
    begin
      List := TList<Integer>.Create();
      List.Add(111);
      List.Add(222);
      List.Add(333);
    
      List.Insert(0, 444);
      List.Insert(2, 555);
    
      str := '';
      for i in List do str := str + UIntToStr(i) + ' '; {444 111 555 222 333 }
      ShowMessage(str);
    
      List.Delete(0);
      List.Delete(List.Count-1);
    
      str := '';
      for i in List do str := str + UIntToStr(i) + ' '; {111 555 222 }
      ShowMessage(str);
    
      List.Remove(555); {删除指定元素}
    
      str := '';
      for i in List do str := str + UIntToStr(i) + ' '; {111 222 }
      ShowMessage(str);
    
      List.Extract(222); {提取指定元素}
    
      str := '';
      for i in List do str := str + UIntToStr(i) + ' '; {111 }
      ShowMessage(str);
      
      List.Free;
    end;
    
    end.
    
  • 相关阅读:
    搜索1009
    搜索1004
    Java文件操作
    搜索1007
    连接查询
    SQL学习——数据类型
    SQL学习——基本语法
    <转载>GIS数据下载网站大全
    DOM查询练习
    day09【继承、super、this、抽象类】
  • 原文地址:https://www.cnblogs.com/del/p/1580697.html
Copyright © 2011-2022 走看看