---------------------------------------------------------------------------- -- PACKAGE: -- Abstract_Sets -- AUTHOR: -- Yoav Tzruya -- EXPRTED TYPES: -- Set - A generic (on set_element) controlled set of elements -- EXPORTED PROCEDURES: -- Empty - return an empty set -- Unit - return a set of one element -- Union - unify two sets into one (no duplicates of course) -- Intersection - the intersection of two sets. -- Take - take an arbitrary element out of the set. -- to_string - represent the set by a string of chars. -- EXPORTED EXCEPTIONS: -- set_is_empty_exception - may be raised by the Take procedure when -- trying to take an element out of the empty set. ---------------------------------------------------------------------------- -- ** SPECIFICATION IMPORTS ** with Ada.Finalization; generic -- the generic element of the set type Set_Element is private; -- a function to convert one element to a string with function to_string ( element_arg : in set_element ) return string; package Abstract_Sets is -- ** EXPORTED EXCEPTIONS ** set_is_empty_exception : exception; -- ** EXPORTED TYPES ** type Set is abstract new Ada.Finalization.Controlled with private; -- ** EXPORTED SUBPROGRAMS ** function Empty return Set is abstract; -- empty set function Unit ( Element : in Set_Element) return Set is abstract; -- build set with 1 element function Union ( Left : in Set; Right : in Set) return Set is abstract; function Intersection ( Left : in Set; Right : in Set) return Set is abstract; procedure Take ( From : in out Set; Element : out Set_Element) is abstract; function to_string ( set_arg : in set'class) return string; private type Set is abstract new Ada.Finalization.Controlled with null record; end Abstract_Sets;