DEADSOFTWARE

migrating from PanelIDs to panel GUIDs; part one
[d2df-sdl.git] / src / shared / hashtable.pas
index 190d4e62b57cb9c9b9941bc78dec401239aaf0d2..ea71555c68ff7a6d4c4fa2db980990e96f41d8e0 100644 (file)
@@ -59,7 +59,7 @@ type
         mEntries: TEntryArray;
         mFirstEntry, mLastEntry, cur: Integer;
       public
-        constructor Create (aents: TEntryArray; afirst, alast: Integer);
+        constructor Create (const aents: TEntryArray; afirst, alast: Integer);
         function MoveNext (): Boolean; inline;
         function getCurrent (): ValueT; inline;
         property Current: ValueT read getCurrent;
@@ -70,7 +70,7 @@ type
         mEntries: TEntryArray;
         mFirstEntry, mLastEntry, cur: Integer;
       public
-        constructor Create (aents: TEntryArray; afirst, alast: Integer);
+        constructor Create (const aents: TEntryArray; afirst, alast: Integer);
         function MoveNext (): Boolean; inline;
         function getCurrent (): KeyT; inline;
         property Current: KeyT read getCurrent;
@@ -81,7 +81,7 @@ type
         mEntries: TEntryArray;
         mFirstEntry, mLastEntry, cur: Integer;
       public
-        constructor Create (aents: TEntryArray; afirst, alast: Integer);
+        constructor Create (const aents: TEntryArray; afirst, alast: Integer);
         function MoveNext (): Boolean; inline;
         function getCurrent (): PEntry; inline;
         property Current: PEntry read getCurrent;
@@ -173,6 +173,11 @@ 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;
+
+
 implementation
 
 uses
@@ -204,7 +209,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);
@@ -945,7 +950,7 @@ end;
 
 
 // ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TValEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
+constructor THashBase.TValEnumerator.Create (const aents: TEntryArray; afirst, alast: Integer);
 begin
   mEntries := aents;
   mFirstEntry := afirst;
@@ -970,7 +975,7 @@ end;
 
 
 // ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TKeyEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
+constructor THashBase.TKeyEnumerator.Create (const aents: TEntryArray; afirst, alast: Integer);
 begin
   mEntries := aents;
   mFirstEntry := afirst;
@@ -995,7 +1000,7 @@ end;
 
 
 // ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TKeyValEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
+constructor THashBase.TKeyValEnumerator.Create (const aents: TEntryArray; afirst, alast: Integer);
 begin
   mEntries := aents;
   mFirstEntry := afirst;