lcore.org gitweb
/
lcore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add linux syscall sys_getrandom to lcorernd
[lcore.git]
/
bsearchtree.pas
diff --git
a/bsearchtree.pas
b/bsearchtree.pas
index 9dc355e08a1b389575789363052d607393df5519..249a6ff3c066e48b9f19b2777a3ae97f4be5c8b3 100644
(file)
--- a/
bsearchtree.pas
+++ b/
bsearchtree.pas
@@
-7,6
+7,9
@@
\r
unit bsearchtree;
\r
\r
\r
unit bsearchtree;
\r
\r
+{$ifdef fpc}
\r
+ {$mode delphi}
\r
+{$endif}
\r
interface
\r
\r
uses blinklist;
\r
interface
\r
\r
uses blinklist;
\r
@@
-37,18
+40,21
@@
procedure cleartree(t:phashtable);
\r
implementation
\r
\r
\r
implementation
\r
\r
+//FNV-1a hash function
\r
function makehash(s:ansistring):integer;
\r
const
\r
shifter=6;
\r
var
\r
a,b:integer;
\r
function makehash(s:ansistring):integer;
\r
const
\r
shifter=6;
\r
var
\r
a,b:integer;
\r
+ h:longword;
\r
begin
\r
result := 0;
\r
b := length(s);
\r
begin
\r
result := 0;
\r
b := length(s);
\r
+ h := 216613626;
\r
for a := 1 to b do begin
\r
for a := 1 to b do begin
\r
-
result := (result shl shifter) xor byte(s[a])
;
\r
+
h := (h xor byte(s[a])) * 16777619
;
\r
end;
\r
end;
\r
- result :=
(result xor result shr 16)
and (hashtable_size-1);
\r
+ result :=
h
and (hashtable_size-1);
\r
end;
\r
\r
procedure addtree(t:phashtable;s:ansistring;item:pointer);
\r
end;
\r
\r
procedure addtree(t:phashtable;s:ansistring;item:pointer);
\r