X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/c1c7500bc32248d67b6cf7903a6db7b15e2cd1c9..3f8290b4a13c15cf62776aa427f62a8ae77ee07c:/bsearchtree.pas diff --git a/bsearchtree.pas b/bsearchtree.pas index 9dc355e..249a6ff 100644 --- a/bsearchtree.pas +++ b/bsearchtree.pas @@ -7,6 +7,9 @@ unit bsearchtree; +{$ifdef fpc} + {$mode delphi} +{$endif} interface uses blinklist; @@ -37,18 +40,21 @@ procedure cleartree(t:phashtable); implementation +//FNV-1a hash function function makehash(s:ansistring):integer; const shifter=6; var a,b:integer; + h:longword; begin result := 0; b := length(s); + h := 216613626; for a := 1 to b do begin - result := (result shl shifter) xor byte(s[a]); + h := (h xor byte(s[a])) * 16777619; end; - result := (result xor result shr 16) and (hashtable_size-1); + result := h and (hashtable_size-1); end; procedure addtree(t:phashtable;s:ansistring;item:pointer);