home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
generic_dictionary.ads
< prev
next >
Wrap
Text File
|
1997-03-24
|
2KB
|
68 lines
-- generic_dictionary.ads
--
-- Copyright (c) 1996 Cadre Technologies Inc, All Rights Reserved
--
-- This file contains the specification for a simple, unoptimized, generic
-- dictionary package that is provided without any express or implied
-- warranties and is intended for interim use in order to allow the
-- compilation and linking of the generated Ada code. This package should
-- ultimately be replaced by a production quality version such as from the
-- compiler vendor's program library.
generic
type Key is private;
type Value is private;
package Generic_Dictionary is
type Dictionary is private;
Already_Exists : exception;
Does_Not_Exist : exception;
-- Add value V with key K to dictionary D
procedure Add(D : in out Dictionary; K : Key; V : Value);
-- Raises Already_Exists if value with key K already exists in D
-- Remove value with key K from dictionary D
procedure Remove(D : in out Dictionary; K : Key);
-- Raises Does_Not_Exist if value with key K does not exist in D
-- Remove all values from dictionary D
procedure Remove_All(D : in out Dictionary);
-- Return whether or not dictionary D contains value with key K
function Has(D : Dictionary; K : Key) return Boolean;
-- Return value for key K from dictionary D
function Find_Value(D : Dictionary; K : Key) return Value;
-- Raises Does_Not_Exist if value for key K does not exist in D
-- Return the number of values in D
function Count(D : Dictionary) return Natural;
-- Iterator
generic
with procedure Process(K : Key; V : Value);
procedure Iterate(D : Dictionary);
private
type Dictionary_Item;
type Dictionary_Item_Acc is access Dictionary_Item;
type Dictionary_Item is record
K : Key;
V : Value;
Next : Dictionary_Item_Acc := null;
end record;
type Dictionary is record
First : Dictionary_Item_Acc := null;
Count : Natural := 0;
end record;
pragma Inline(Count);
end Generic_Dictionary;