DelphiÖеÄTHashTable
ÔÚDelphiÖÐ,Inifilesµ¥ÔªÖÐÓÐÒ»¸öTStringHashµÄÀ࣬²»¹ýËüµÄValue½öÖ§³ÖInteger(ÆäʵҲ²»ÊÇÎÊÌ⣬ÓÐÆäËüÀàÐÍ¿ÉÒÔ½«±äÁ¿±äΪPointer)£¬ÓÐµã²»Êæ·þ£¬½ñÌìûÊÂ×ö¾Í°ÑËüÌæ»»ÎªvariantÁË£¬ÆäÖÐKeyµÄÃû³Æ´óСдÎ޹أ¬¾ÍÊÇΪÁ˼ӿ쿪·¢ËÙ¶È£¡
ʹÓÃHashtable,²éÕÒºÍɾ³ý¸´ÔӶȶ¼Êdz£Êý¼¶±ðµÄ!
type
PPHashItem = ^PHashItem;
PHashItem = ^THashItem;
THashItem = record
Next: PHashItem;
Key: String;
Value: Variant;
end;
THashTable = class
private
Buckets: array of PHashItem;
protected
function Find(const Key: String): PPHashItem;
function HashOf(const Key: String): Cardinal; virtual;
public
constructor Create(Size: Cardinal = 256);
destructor Destroy; override;
procedure Put(const Key: String; Value: Variant);
procedure Clear;
procedure Remove(const Key: String);
function Modify(const Key: String; Value: Variant): Boolean;
function Get(const Key: String): Variant;
function ContainKey(const Key: String):boolean;
end;
procedure THashTable.Clear;
var
I: Integer;
P, N: PHashItem;
begin
for I := 0 to Length(Buckets) - 1 do
begin
P := Buckets[I];
while P <> nil do
begin
N := P^.Next;
Dispose(P);
P := N;
end;
Buckets[I] := nil;
end;
end;
function THashTable.ContainKey(const Key: String): boolean;
var
P: PHashItem;
begin
P := Find(Key)^;
if P <> nil then
begin
Result := True;
end
else
Result := False;
end;
constructor THashTable.Create(Size: Cardinal);
begin
inherited Create;
SetLength(Buckets, Size);
end;
destructor THashTable.Destroy;
begin
Clear;
inherited Destroy;
end;
function THashTable.Find(const Key: String): PPHashItem;
var
Hash: Integer;
begin
Hash := HashOf(Key) mod Cardinal(Length(Buckets));
Result := @Buckets[Hash];
while Result^ <> nil do
begin
if Result^.Key = Key then
Exit
else
Result := @Result^.Next;
end;
end;
functio
Ïà¹ØÎĵµ£º
Format
typeµÄ¿ÉÄÜÖµÓÐÏÂÁÐÕâЩ£º
(1) d ÓзûºÅÊ®½øÖÆÊý
Args±ØÐëÊÇÓзûºÅÕûÐÍÊý¡£Èç¹ûÔÚ¸ñʽ»¯×Ö·û´®Öл¹¼ÓÈëÁË["." prec]£¬ÔòÈç¹ûArgs
µÄ³¤¶ÈÈç¹ûСÓÚ¸ø³öµÄ¾«¶ÈÊýʱ£¬ÔÚǰ±ßÌî²¹0£»Èç¹û´óÓÚ¾«¶ÈÊý£¬°´Êµ¼Ê³¤¶ ......
var
arrChar : array [0..4] of Char;
b : Byte;
s : string;
begin
s := 'Test';
Move(Pointer(s)^, arrChar, Length(s)); //string to array of char
ShowMessage(arrChar);
b := Ord(s[1]); //First byte string to one single byte
......
ÏÖÔÚÓ¦ÓÃϵͳÁ÷ÐÐÓÃB/S¿ª·¢£¬Ô缸Äêǰ¿ÉÊÇC/SµÄÌìÏÂÄØ£¬ÎÒÏÖÔÚ×öµÄijº½¿Õ¹«Ë¾»õÔ˽áËãά»¤¹¤×÷£¬Æäϵͳ¾ÍÊÇÀûÓÃDelphi¿ª·¢µÄC/SÓ¦ÓóÌÐò£¡ÔÚÈÕ³£µÄά»¤¹¤×÷ÖУ¬ÄÑÃâÒª¶ÔÒѾ×öºÃµÄCOM+×é¼þ½øÐе÷ÊÔ£¬ÒԲ鿴¾ßÌåµÄ´¦ÀíÂß¼£¡±¾ÎľÍÊǽéÉÜÔÚWindowsXP»·¾³ÏÂÈçºÎÔÚDelphiÖе÷ÊÔCOM+×é¼þ£¡
µÚÒ»²½£º¼Ç¼ÏÂÄãÏ£Íûµ÷ÊÔµÄCOM+×é¼þ ......
delphiÖйú¼Ê»¯µÄ¼¸ÖÖ·½°¸¼°±È½Ï(ת)
Ëæ×ÅÈ«Çò»¯³Ì¶È¼ÓÉÈí¼þÔ½À´Ô½ÏñÆÑ¹«Ó¢£¬µ½´¦Æ®É¢¡¢Ôú¸ù¡£ÕâÆäÖÐÒª½â¾öµÄÊDz»Í¬ÓïÑÔµÄÏÔʾÎÊÌâ¡£ÎÒÃǵ±È»Ï£ÍûÒ»Ì׳ÌÐò£¬¿ÉÒÔ²»Ð޸ĴúÂë¾Í¿ÉÒÔÖ§³Ö²»Í¬µÄÓïÑÔ£¬²»ÒªÈ¥Î¬»¤ºÜ¶àµÄ°æ±¾¡£
Ê×ÏÈҪ̸µ½µÄÒ»¸öÎÊÌâÊÇÂÒÂëÎÊÌ⣬ÒòΪdelphi
wi ......
½ñÌìÏîÄ¿×é·¢ÉúÒ»¸öÊÂÇé¾ÍÊÇ£¬ºǫ́aixÉ϶ԶàÓïÑÔÎı¾£¨Ó¢Óï+ºº×Ö£©»»ÐÐÎÊÌâ¸ã²»Ì«Çå³þ¡£
×îÔçǰ̨µÄ¶à×Ö·ûµÄ´úÂëÎÒ¼ì²éÁËһϣ¨°´ÕÕ0-128ÒÔÍâËãÖÐÎĵĴúÂ룩·¢ÏÖ²»Êǰ²È«µÄ´úÂë¡£
(delphi 7.0)
delphi°²È«µÄ»ìºÏ×Ö·ûµÄ²Ù×÷·½·¨ÊÇ£º
ÔÚstrsUtilsµ¥ÔªÖÐ
leftstr
MidStr
Rightstr
aixÏÂÊÇ£º ......