1 ÏØÙÚgeneric
 2 ÏÏ§Ïtype Element_Type is (<>);  -- This parameter will match any discrete type
 3 ÏÏ§Ïpackage Discrete_Set is
 4 ÏÏ§
 5 ÏÏ§-- This package implements an ADT for a set of discrete elements
 6 ÏÏ§
 7 ÏÏ§ÏïÏtype Set_Type is private;
 8 ÏÏ§
 9 ÏÏ§ÏíÏEmpty_Set     : constant Set_Type; -- A set with no elements
10 ÏÏ§ÏíÏUniversal_Set : constant Set_Type; -- A set with all possible elements
11 ÏÏ§
12 ÏÏ§----------------------------------------------------------------------------
13 ÏÏ§ÏÛÜÝfunction Is_Member (Set     : in Set_Type;
14 ÏÏ§ÏÏ©Ï                Element : in Element_Type) return Boolean;
15 ÏÏ§-- This function determines whether Element is a member of Set
16 ÏÏ§
17 ÏÏ§----------------------------------------------------------------------------
18 ÏÏ§ÏÛÜÝfunction "+" (Left : in Set_Type; Right : in Set_Type) return Set_Type;
19 ÏÏ§-- Returns the union of the two sets
20 ÏÏ§-- (elements that are in either or both sets)
21 ÏÏ§
22 ÏÏ§----------------------------------------------------------------------------
23 ÏÏ§ÏÛÜÝfunction "+" (Left : in Set_Type; Right : in Element_Type) return Set_Type;
24 ÏÏ§-- Adds an element to a set
25 ÏÏ§-- (the set is not changed if the element is already a member)
26 ÏÏ§
27 ÏÏ§----------------------------------------------------------------------------
28 ÏÏ§ÏÛÜÝfunction "+" (Left : in Element_Type; Right : in Set_Type) return Set_Type;
29 ÏÏ§-- Adds an element to a set
30 ÏÏ§-- (the set is not changed if the element is already a member)
31 ÏÏ§
32 ÏÏ§----------------------------------------------------------------------------
33 ÏÏ§ÏÛÜÝfunction "*" (Left : in Set_Type; Right : in Set_Type) return Set_Type;
34 ÏÏ§-- Returns the intersection of the two sets
35 ÏÏ§-- (elements occurring in both sets)
36 ÏÏ§
37 ÏÏ§----------------------------------------------------------------------------
38 ÏÏ§ÏÛÜÝfunction "-"  (Left : in Set_Type; Right : in Set_Type) return Set_Type;
39 ÏÏ§-- Returns the difference of the two sets
40 ÏÏ§-- (elements in Left and not in Right)
41 ÏÏ§
42 ÏÏ§----------------------------------------------------------------------------
43 ÏÏ§ÏÛÜÝfunction "-" (Left : in Set_Type; Right : in Element_Type) return Set_Type;
44 ÏÏ§-- Removes an element from the set
45 ÏÏ§-- (the set is not changed if the element is not a member)
46 ÏÏ§
47 ÏÏ§
48 ÏÏ§----------------------------------------------------------------------------

49 ÏÏ§--                       Relational Set Operators
50 ÏÏ§--                The equality operators (= and /=) are
51 ÏÏ§--               available for the private type Set_Type
52 ÏÏ§----------------------------------------------------------------------------
53 ÏÏ§
54 ÏÏ§ÏÛÜÝfunction "<=" (Left : in Set_Type; Right : in Set_Type) return Boolean;
55 ÏÏ§-- Returns True if Left is a subset of Right
56 ÏÏ§
57 ÏÏ§ÏÛÜÝfunction "<" (Left : in Set_Type; Right : in Set_Type) return Boolean;
58 ÏÏ§-- Returns True if Left is a proper subset of Right
59 ÏÏ§
60 ÏÏ§ÏÛÜÝfunction ">=" (Left : in Set_Type; Right : in Set_Type) return Boolean;
61 ÏÏ§-- Returns True if Right is a subset of Left
62 ÏÏ§
63 ÏÏ§ÏÛÜÝfunction ">" (Left : in Set_Type; Right : in Set_Type) return Boolean;
64 ÏÏ§-- Returns True if Right is a proper subset of Left
65 ÏÏ§
66 ÏÏ§
67 ÏÏ§private
68 ÏÏ§
69 ÏÏ§ÏïÏtype Set_Type is array (Element_Type) of Boolean;      
70 ÏÏ§
71 ÏÏ§-- Completion of deferred constants
72 ÏÏ§ÏíÏEmpty_Set     : constant Set_Type := (Element_Type => False);
73 ÏÏ§ÏíÏUniversal_Set : constant Set_Type := (Element_Type => True); 
74 ÏÏ§
75 ÏÏ©end Discrete_Set;