在Delphi里实现[int map string]对
Type
TIntToStrArray = Array[0..65535] Of PChar;
//有序类型不能设为Integer,[Error] :Data type too large: exceeds 2 GB
//也不能设太大,会占很大内存
//在方法里声明最好小些,全局里可以大些

Var
aIntToStrArray: TIntToStrArray;
Begin
aIntToStrArray[1]:='a[1]';
End;
{===========================================}
一般应用在字符串的替换上,提高效率,以空间换时间。

Type
TSynReplaceCharsArray = Array[char] Of PChar;

Var
fReplaceReserved: TSynReplaceCharsArray;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
fReplaceReserved[#153] := '™';
fReplaceReserved[#224] := 'À';
fReplaceReserved[#225] := 'Á';
End;
{===========================================}
Type
TSynReplaceCharsArray = Array[Widechar] Of PChar;

Var
fReplaceReserved: TSynReplaceCharsArray;

Procedure TForm1.FormCreate(Sender: TObject);
Begin
fReplaceReserved[Widechar(153)] := '™';
fReplaceReserved[Widechar(224)] := 'À';
fReplaceReserved[Widechar(225)] := 'Á';
End;
{===========================================}