K
kun
Unregistered / Unconfirmed
GUEST, unregistred user!
在单元IniFiles中:
function TStringHash.HashOf(const Key: string): Cardinal;
var
I: Integer;
begin
Result := 0;
for I := 1 to Length(Key)do
Result := ((Result shl 2) or (Result shr (SizeOf(Result) * 8 - 2))) xor
Ord(Key);
end;
function TStringHash.Find(const Key: string): PPHashItem;
var
Hash: Integer;
begin
Hash := HashOf(Key) mod Cardinal(Length(Buckets));
Result := @Buckets[Hash];
while Result^ <> nildo
begin
if Result^.Key = Key then
Exit
else
Result := @Result^.Next;
end;
end;
如果key相同,那找回来的value就可能不是我想要找的了。
function TStringHash.HashOf(const Key: string): Cardinal;
var
I: Integer;
begin
Result := 0;
for I := 1 to Length(Key)do
Result := ((Result shl 2) or (Result shr (SizeOf(Result) * 8 - 2))) xor
Ord(Key);
end;
function TStringHash.Find(const Key: string): PPHashItem;
var
Hash: Integer;
begin
Hash := HashOf(Key) mod Cardinal(Length(Buckets));
Result := @Buckets[Hash];
while Result^ <> nildo
begin
if Result^.Key = Key then
Exit
else
Result := @Result^.Next;
end;
end;
如果key相同,那找回来的value就可能不是我想要找的了。