在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;
{===========================================}
原文来自: 【100脚本网 http://www.pc100.net/ 】
【转载来自:
在Delphi里实现[int map string]对[delphi]
】。