Hosted by
 |
with Interfaces;
use Interfaces;
package body String_Hash_Tables is
function Hash
(Key : in Unbounded_String;
Max : in Positive)
return Positive
is
use type Unsigned_32;
Key_String : String := To_String(Key);
Collect : Unsigned_32 := 0;
begin
for Index in Key_String'Range loop
Collect := Collect + Character'Pos(Key_String(Index));
Collect := Rotate_Right(Collect, 13);
end loop;
return Positive(Collect mod Unsigned_32(Max) + 1);
end Hash;
procedure Put
(Table : in out Hash_Table;
Key : in String;
Item : in Item_Type)
is
begin
US_Hash_Tables.Put(Table, To_Unbounded_String(Key), Item);
end Put;
procedure Get
(Table : in Hash_Table;
Key : in String;
Item : out Item_Type;
Found : out Boolean)
is
begin
US_Hash_Tables.Get(Table, To_Unbounded_String(Key), Item, Found);
end Get;
function Get
(Table : in Hash_Table;
Key : in String)
return Item_Type
is
begin
return US_Hash_Tables.Get(Table, To_Unbounded_String(Key));
end Get;
end String_Hash_Tables;
|