Hosted by
 |
generic
type Key_Type is private;
type Item_Type is private;
with function Hash
(Key : in Key_Type;
Max : in Positive)
return Positive;
with function "="
(Left, Right : in Key_Type)
return Boolean
is <>;
package Hash_Tables is
Default_Start_Size : constant := 13;
Max_Fill_Percentage : constant := 60;
type Hash_Table is private;
Key_Exists : exception;
procedure Put
(Table : in out Hash_Table;
Key : in Key_Type;
Item : in Item_Type);
procedure Get
(Table : in Hash_Table;
Key : in Key_Type;
Item : out Item_Type;
Found : out Boolean);
Key_Not_Found : exception;
function Get
(Table : in Hash_Table;
Key : in Key_Type)
return Item_Type;
procedure Get_Next
(Table : in Hash_Table;
Index : in out Natural;
Key : out Key_Type;
Item : out Item_Type);
procedure Print_Usage
(Table : in Hash_Table);
private
type Pair is record
Empty : Boolean := True;
Key : Key_Type;
Item : Item_Type;
end record;
type Pair_Array is array(Natural range <>) of Pair;
type Hash_Table_Record(Size : Positive) is
record
Count : Natural;
Pairs : Pair_Array(1 .. Size);
end record;
type Hash_Table is access Hash_Table_Record;
end Hash_Tables;
|