----------------------------------------------------------------------------- -- PACKAGE: -- Array_Sets -- AUTHOR: -- Yoav Tzruya -- EXPORTED TYPES: -- Set - derived from absrtact_sets.set - a set implemented by -- size changing array (dynamically allocated) -- EXPORTED PROCEDURES: -- (see abstract_sets.ads) -- EXPORTED EXCEPTIONS: -- (see abstract_sets.ads) ----------------------------------------------------------------------------- -- ** SPECIFICATION IMPORTS ** with Abstract_Sets; generic -- the type of element in 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; -- an abstract set of elements with package abstract_set_handling is new abstract_sets(set_element=> set_element,to_string=> to_string); package Array_Sets is -- ** EXPORTED EXCEPTIONS ** set_is_empty_exception : exception renames abstract_set_handling.set_is_empty_exception; -- ** EXPORTED TYPES ** type Set is new Abstract_Set_Handling.set with private; -- ** EXPORTED SUBPROGRAMS ** function Empty return Set; -- empty set function Unit ( Element : in Set_Element) return Set; -- build set with 1 element function Union ( Left : in Set; Right : in Set) return Set; function Intersection ( Left : in Set; Right : in Set) return Set; procedure Take ( From : in out Set; Element : out Set_Element); -- may raise the following exceptions : -- o set_is_empty_exception function to_String ( Set_arg : in Set) return String; private procedure Adjust (Object : in out Set); procedure Finalize (Object : in out Set); type Element_Array is array (integer range <>) of Set_Element; type Access_Element_Array is access Element_Array; type Set is new Abstract_Set_Handling.Set with record Elements : Access_Element_Array := null; end record; end Array_Sets;