home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
generic_unordered_set.ads
< prev
next >
Wrap
Text File
|
1997-10-20
|
2KB
|
60 lines
-- generic_unordered_set.ads
--
-- Copyright (c) 1996 Cadre Technologies Inc, All Rights Reserved
--
-- This file contains the specification for a simple, unoptimized, generic
-- unordered set 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 Element is private;
package Generic_Unordered_Set is
type Unordered_Set is private;
Already_Exists : exception;
Does_Not_Exist : exception;
-- Add element E to set S; raises Already_Exists if E already exists in S
procedure Add(S : in out Unordered_Set; E : Element);
-- Remove element E from set S; raises Does_Not_Exist if S doesn't have E
procedure Remove(S : in out Unordered_Set; E : Element);
-- Remove all elements from set S
procedure Remove_All(S : in out Unordered_Set);
-- Return whether or not set S contains element E
function Has(S : Unordered_Set; E : Element) return Boolean;
-- Return the number of elements in S
function Count(S : Unordered_Set) return Natural;
-- Iterator
generic
with procedure Process(E : Element);
procedure Iterate(S : Unordered_Set);
private
type Unordered_Set_Item;
type Unordered_Set_Item_Acc is access Unordered_Set_Item;
type Unordered_Set_Item is record
Elem : Element;
Next : Unordered_Set_Item_Acc := null;
end record;
type Unordered_Set is record
First : Unordered_Set_Item_Acc := null;
Count : Natural := 0;
end record;
pragma Inline(Count);
end Generic_Unordered_Set;