X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/c1c7500bc32248d67b6cf7903a6db7b15e2cd1c9..21410d99e1361e5474a47bb0bd0bc6e939f91b7d:/bsearchtree.pas?ds=sidebyside diff --git a/bsearchtree.pas b/bsearchtree.pas index 9dc355e..9ec804c 100644 --- a/bsearchtree.pas +++ b/bsearchtree.pas @@ -37,18 +37,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);