-- $Date: 2004/01/28 05:17:33 $
-- $Revision: 1.11 $
-- $Author: jcrocholl $

package body Hash_Tables is

   -- Check for available space in the table, grow if necessary, then
   -- insert the key item pair into the table.
   -- Raises Key_Exists if the key is already in use.
   procedure Put
     (This : in out Hash_Table_Access-- Add pair to this hash table.
      Key  : in Key_Type;              -- Create this key.
      Item : in Item_Type)             -- Associate this item.
   is
      Pair : Inner_Tables.Pair_Access := new Inner_Tables.Pair;
   begin
      Pair.Key := Key;
      Pair.Item := Item;
      Inner_Tables.Put(This, Pair);
   end Put;

   -- Retrieve an item from the table.
   -- Raises Key_Not_Found if the key is not in the table.
   function Get
     (This : access Hash_Table-- Get value from this hash table.
      Key  : in Key_Type)       -- Look up this key.
     return Item_Type is        -- The item that was found.
   begin
      return Inner_Tables.Get_Item(This, Inner_Tables.Get_Index(This, Key));
   end Get;

   -- Iterate over the items in the table. You should start with an
   -- Index of 0 and stop iterating as soon as Index is 0 again.
   procedure Get_Next
     (This  : access Hash_Table-- Get pair from this hash table.
      Index : in out Natural;    -- Iteration pointer to the current field.
      Key   : out Key_Type;      -- The key at the updated index position.
      Item  : out Item_Type)     -- The item at the updated index position.
   is
      Pair : Inner_Tables.Pair_Access;
   begin
      Inner_Tables.Get_Next(This, Index, Pair);
      Key := Pair.Key;
      Item := Pair.Item;
   end Get_Next;

end Hash_Tables;