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