X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fshared%2Fhashtable.pas;h=8aaa522a45bae64530243a8fa031f42b4b035b4f;hb=3d8489bb2d74d08d3a9ccad06eea7e8fb7d4038d;hp=9f72e3ab2f5fb547da371473cc30e87e8b47887b;hpb=1a10061a1cd706f5f06b923740e45a462d2bd885;p=d2df-sdl.git diff --git a/src/shared/hashtable.pas b/src/shared/hashtable.pas index 9f72e3a..8aaa522 100644 --- a/src/shared/hashtable.pas +++ b/src/shared/hashtable.pas @@ -161,9 +161,11 @@ type type THashIntInt = specialize THashBase; THashStrInt = specialize THashBase; + THashStrStr = specialize THashBase; function hashNewIntInt (): THashIntInt; function hashNewStrInt (): THashStrInt; +function hashNewStrStr (): THashStrStr; function u32Hash (a: LongWord): LongWord; inline; @@ -173,6 +175,13 @@ function joaatHash (constref buf; len: LongWord): LongWord; function nextPOT (x: LongWord): LongWord; inline; +// for integer keys +function hiiequ (constref a, b: Integer): Boolean; +function hiihash (constref k: Integer): LongWord; +function hsiequ (constref a, b: AnsiString): Boolean; +function hsihash (constref k: AnsiString): LongWord; + + implementation uses @@ -204,7 +213,7 @@ function hsiequ (constref a, b: AnsiString): Boolean; begin result := (a = b); e {$RANGECHECKS OFF} function hiihash (constref k: Integer): LongWord; begin - result := k; + result := LongWord(k); result -= (result shl 6); result := result xor (result shr 17); result -= (result shl 9); @@ -233,6 +242,12 @@ begin end; +function hashNewStrStr (): THashStrStr; +begin + result := THashStrStr.Create(hsihash, hsiequ); +end; + + // ////////////////////////////////////////////////////////////////////////// // {$PUSH} {$RANGECHECKS OFF}