----------------------------------------------------------------------------- -- PACKAGE: -- List_Sets -- AUTHOR: -- Yoav Tzruya -- EXPORTED TYPES: -- Set - derived from absrtact_sets.set - a set implemented by -- a dynamic list and controlled by finailize and adjust -- EXPORTED PROCEDURES: -- (see abstract_sets.ads) -- EXPORTED EXCEPTIONS: -- (see abstract_sets.ads) ----------------------------------------------------------------------------- -- ** SPECIFICATION IMPORTS ** with Abstract_Sets; generic 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 List_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 node; type access_node is access node; type node is record next : access_node := null; elem : set_element; end record; type Set is new Abstract_Set_Handling.Set with record head : access_node; end record; end List_Sets;