| ASCL User's Guide: ASCL, ADA Standard Component Library; Version 0.1.0; Document Revision $Revision: 1.7 $ | ||
|---|---|---|
| Prev | Chapter 27. ASCL.Data_Structures.Dictionary | Next |
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 ) is private; Table_Full : exception; Key_Already_Used : exception; Key_Not_Existing : exception;
This procedure stores the value of Element_Type in the dictionary with the given key.
P.1 - Number of stored elements < capacity. P.3 - Key not already stored.
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.
Table_Full - P.2 violated
Key_Already_Used - P.3 violated and Update = False
procedure Put(
This : in out Dictionary_Type;
Key : in Key_Type;
Value : in Element_Type;
Update : in Boolean := False );
Retrieve a dictionary element from the dictionary
P.1 - Key exisits
C.1 - Funtion yield handle to copy of the dictionary element
Key_Not_Existing - P.1 violated
None
function Get(
This : in Dictionary_Type;
Key : in Key_Type ) return Element_Type;
Remove a key from the dictionary
P.1 - Key exists in dictionary
C.1 - The object is removed.
C.2 - The number of elements in the dictionary is decremented by 1.
Key_Not_Existing - P.1 violated
procedure Remove(
This : in out Dictionary_Type;
Key : in Key_Type );
Clear the dictionary
None
C.1 - All objects entires stored in the dictionary are made
invalid.
C.2 - The nbr of free entries = capacity.
None
None
procedure Clear(
This : in out Dictionary_Type);
Check if empty
None
C.1 - return true if nbr_of_entries = 0
None
function Is_Empty(
This : in Dictionary_Type) return Boolean;
check if key or a element is in the dictionary
None
C.1 - either true or false or the key handle.
None
function Contains(
This : in Dictionary_Type;
Key : in Key_Type ) return Boolean;
function Size(
This : in Dictionary_Type ) return Natural;
Returns the list of all keys in a dictionary
P.1 - The number of entries in the dictionary is not larger then
the provided dictionary table
C.1 - length is set to the actual number of entries in the
dictionary.
Dictionary_Overflow - P.1 violated.
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(
This : in Dictionary_Type;
Keys : out Dictionary_Table;
Length : out Natural );
Dictionary_Overflow : exception;