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.
    
  • 相关阅读:
    tomcat 乱码问题
    mongo获取lbs数据
    sping mvc+uploadify 上传文件大小控制3部曲
    jstack 查看线程状态
    nginx 限流配置
    查找占用CPU高线程
    redis sentinel无法启动问题
    GC垃圾回收机制
    ASP.NET 生命周期
    Javascript验证手机号码正则表达式
  • 原文地址:https://www.cnblogs.com/del/p/1580697.html
Copyright © 2011-2022 走看看