Hosted by
|
generic
type Key_Type is limited private;
type Item_Type is limited private;
with function Hash
(Key : in Key_Type;
Max : in Positive)
return Positive
is <>;
with function Equal
(Left, Right : in Key_Type)
return Boolean
is <>;
package Limited_Hash_Tables is
Default_Start_Size : constant := 13;
Max_Fill_Percentage : constant := 60;
type Pair is limited record
Key : Key_Type;
Item : Item_Type;
end record;
type Pair_Access is access Pair;
type Hash_Table(Size : Positive) is private;
type Hash_Table_Access is access Hash_Table;
function Create
(Size : in Positive := Default_Start_Size)
return Hash_Table_Access;
Key_Exists : exception;
procedure Put
(This : in out Hash_Table_Access;
Pair : in Pair_Access);
procedure Get_Index
(This : access Hash_Table;
Key : in Key_Type;
Index : out Positive;
Found : out Boolean);
Key_Not_Found : exception;
function Get_Index
(This : access Hash_Table;
Key : in Key_Type)
return Positive;
function Get_Pair
(This : access Hash_Table;
Index : in Positive)
return Pair_Access;
function Get_Key
(This : access Hash_Table;
Index : in Positive)
return Key_Type;
function Get_Item
(This : access Hash_Table;
Index : in Positive)
return Item_Type;
procedure Next
(This : access Hash_Table;
Index : in out Natural);
procedure Get_Next
(This : access Hash_Table;
Index : in out Natural;
Pair : out Pair_Access);
procedure Print_Usage
(This : access Hash_Table);
private
type Pair_Array is array(Positive range <>) of Pair_Access;
type Hash_Table(Size : Positive) is
record
Count : Natural;
Pairs : Pair_Array(1 .. Size);
end record;
end Limited_Hash_Tables;
|