zl程序教程

您现在的位置是:首页 >  其它

当前栏目

如何使用THashedStringList

如何 使用
2023-09-27 14:29:11 时间

1.添加

uses system.IniFiles

2.实例代码:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,System.IniFiles, Vcl.StdCtrls;
type
  Ps=^string;
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    gg:THashedStringList;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  str:string;
  PP:Ps;
  I:Integer;
begin
 gg:=THashedStringList.Create;
 gg.Sort;
 for I := 0 to 500000 do
   begin
     str:=IntToStr(i)+'MM';
     pp:=Addr(str);
     gg.AddObject(IntToStr(i),TObject(Integer(pp)));
     Self.Button1.Caption :=IntToStr(gg.IndexOf(IntToStr(i)));
   end;

end;

end.

本例程在delphi XE6下通过。