API Reference

Generic Package Parameter(s)

   type Key_Type is private; 
   type Element_Type is private; 
 
   with function Is_Equal( 
      A, B : in Key_Type ) return Boolean is "="; 
 

type Dictionary_Type( Capacity : Natural )

 
   type Dictionary_Type( Capacity : Natural ) is private; 
 
   Table_Full        : exception; 
   Key_Already_Used  : exception; 
   Key_Not_Existing  : exception; 
 
Description

This procedure stores the value of Element_Type in the dictionary with the given key.

Preconditions

P.1 - Number of stored elements < capacity. P.3 - Key not already stored.

Postconditions

C.1 - An additional key/value pair has been added to the

container. The number of elements in increased by one if the object was not updated.

Exceptions

Table_Full - P.2 violated

Key_Already_Used - P.3 violated and Update = False

procedure Put

   procedure Put(  
       This   : in out Dictionary_Type; 
       Key    : in Key_Type; 
       Value  : in Element_Type; 
       Update : in Boolean := False ); 
 
Description

Retrieve a dictionary element from the dictionary

Preconditions

P.1 - Key exisits

Postconditions

C.1 - Funtion yield handle to copy of the dictionary element

Exceptions

Key_Not_Existing - P.1 violated

Notes

None

function Get

   function Get(  
       This : in Dictionary_Type; 
       Key  : in Key_Type ) return Element_Type; 
 
Description

Remove a key from the dictionary

Preconditions

P.1 - Key exists in dictionary

Postconditions

C.1 - The object is removed.

C.2 - The number of elements in the dictionary is decremented by 1.

Exceptions

Key_Not_Existing - P.1 violated

procedure Remove

   procedure Remove(  
      This : in out Dictionary_Type; 
      Key  : in Key_Type ); 
 
Description

Clear the dictionary

Preconditions

None

Postconditions

C.1 - All objects entires stored in the dictionary are made

invalid.

C.2 - The nbr of free entries = capacity.

Exceptions

None

Notes

None

procedure Clear

   procedure Clear(  
       This : in out Dictionary_Type); 
 
Description

Check if empty

Preconditions

None

Postconditions

C.1 - return true if nbr_of_entries = 0

Exceptions

None

function Is_Empty

   function Is_Empty(  
      This    : in Dictionary_Type) return Boolean; 
 
Description

check if key or a element is in the dictionary

Preconditions

None

Postconditions

C.1 - either true or false or the key handle.

Exceptions

None

function Contains, function Size

   function Contains(  
      This    : in Dictionary_Type; 
      Key     : in Key_Type ) return Boolean; 
 
 
   function Size( 
      This    : in Dictionary_Type ) return Natural; 
 
Description

Returns the list of all keys in a dictionary

Preconditions

P.1 - The number of entries in the dictionary is not larger then

the provided dictionary table

Postconditions

C.1 - length is set to the actual number of entries in the

dictionary.

Exceptions

Dictionary_Overflow - P.1 violated.

Notes

This procedure is not optimized for speed. In case of large tables this might be a real problem for the performance of your application code.

procedure Dictionary

   procedure Dictionary(  
      This    : in  Dictionary_Type; 
      Keys    : out Dictionary_Table; 
      Length  : out Natural ); 
 
   Dictionary_Overflow : exception;