如何使用THashedStringList

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下通过。

你可能感兴趣的:(如何使用THashedStringList)