set.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, or (at your option) any later version. --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details. --
-- The license text is also available from: Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
--------------> Please email comments to <bug-sather@gnu.org> <--------------
abstract class $RO_SET{ETP} < $RO_BAG{ETP}
abstract class $RO_SET{ETP} < $RO_BAG{ETP} is
-- This abstract class models a non-modifiable mathematical set
-- abstraction.
-- Definition :--
-- A mathematical set is a bag with the added constraint that all
-- elements are unique.
-- This model is a read-only one in which no modifying operations are
-- provided. Subtypes may, of course, provide such modifying operations.
-- Version 1.2 Nov 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 1 Jun 96 bg Original
-- 4 Apr 97 kh Changed for style conformity
-- 12 Nov 98 kh Revised for 1.2
copy : SAME ;
-- This routine returns a copy of the current set.
add(
elem : ETP
) : $VBAG{ETP} ;
-- This routine returns a new bag which contains the values of
-- the elements of self together with the parameter elem.
insert(
elem : ETP
) : $RO_SET{ETP} ;
-- This routine returns a new set containing the elements of self
-- together with the gievn element elem.
delete(
elem : ETP
) : $RO_SET{ETP} ;
-- This routine returns a new set consisting of all of the elements of
-- self except for one which is element equal to elem (if present).
delete_all(
elem : ETP
) : $RO_SET{ETP} ;
-- This routine returns a new set consisting of all of the elements of
-- self except for any which are element equal to elem (if present!).
concat(
arg : $ELT{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag which contains all of the elements of
-- self and arg. For elements which have multiple occurrences then the
-- result contains the sum of the numbers in self and arg.
union(
arg : $RO_BAG{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag contining the elements of self and
-- arg. For elements which occur multiple times the reult contains the
-- larger number of occurrences in self or arg.
union(
arg : $RO_SET{ETP}
) : $RO_SET{ETP} ;
-- This routine returns a new set containing all of the elements of self
-- or arg. It overloads the function in $RO_BAG which has an argument and
-- return value of class $RO_BAG.
intersection(
arg : $RO_BAG{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag containing the elements common to self
-- and arg. For elements with multiple occurrences the result contains the
-- lesser of the number in self and arg.
intersection(
arg : $RO_SET{ETP}
) : $RO_SET{ETP} ;
-- This routine returns a new set containing only the elements which are
-- present both in self and in arg. It overloads the function in $RO_BAG
-- which has an argument and return class of $RO_BAG.
diff(
arg : $RO_SET{ETP}
) : $RO_SET{ETP} ;
-- This routine returns the set which contains only the elements of self
-- not in arg.
sym_diff(
arg : $RO_SET{ETP}
) : $RO_SET{ETP} ;
-- This routine returns a new set containing only the elements of self
-- which are not in arg and vice versa.
end ; -- $RO_SET{ETP}
abstract class $VSET{ETP} < $RO_SET{ETP}, $VBAG{ETP}
abstract class $VSET{ETP} < $RO_SET{ETP}, $VBAG{ETP} is
-- This abstract class defines the complete set abstraction with
-- value semantics!
-- NOTE This value abstraction and is stricter than the read-only abstraction.
-- Subtypes must not support *any* operations that modify self. The
-- language cannot enforce this restriction.
-- Version 1.1 Apr 97. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 1 Nov 96 bg Original for 1.2
-- 12 Nov 98 kh Refined, CARD for INT substitution
copy : SAME ;
-- This routine returns a copy of the current set.
add(
elem : ETP
) : $VBAG{ETP} ;
-- This routine returns a new bag which contains the values of
-- the elements of self together with the parameter elem.
insert(
elem : ETP
) : $VSET{ETP} ;
-- This routine returns a new set containing the elements of self
-- together with the gievn element elem.
delete(
elem : ETP
) : $VSET{ETP} ;
-- This routine returns a new set consisting of all of the elements of
-- self except for one which is element equal to elem (if present).
delete_all(
elem : ETP
) : $VSET{ETP} ;
-- This routine returns a new set consisting of all of the elements of
-- self except for any which are element equal to elem (if present!).
concat(
arg : $ELT{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag containing all of the elements of self
-- and including the given element. For elements that occur multiple times,
-- the result contains the sum of the number of occurences in self and arg.
union(
arg : $RO_BAG{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag which consists of the union of self
-- and arg. For elements that occur multiple times, the result contains
-- the maximum number of occurences in either self or arg.
--
-- NOTE This definition permits the union of sets to be consistent with
-- the union of bags.
union(
arg : $RO_SET{ETP}
) : $VSET{ETP} ;
-- This routine returns a new set containing all of the elements of self
-- or arg. It overloads the function in $RO_BAG which has an argument and
-- return value of class $RO_BAG.
intersection(
arg : $RO_BAG{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag containing only the elements common to
-- both self and arg. For elements that occur multiple times, the result
-- contains the minimum number of occurrences in either self or arg.
intersection(
arg : $RO_SET{ETP}
) : $VSET{ETP} ;
-- This routine returns a new set containing only the elements which are
-- present both in self and in arg. It overloads the function in $RO_BAG
-- which has an argument and return class of $RO_BAG.
diff(
arg : $RO_SET{ETP}
) : $VSET{ETP} ;
-- This routine returns the set which contains only the elements of self
-- not in arg.
sym_diff(
arg : $RO_SET{ETP}
) : $VSET{ETP} ;
-- This routine returns a new set containing only the elements of self
-- which are not in arg and vice versa.
end ; -- $VSET
abstract class $SET{ETP} < $RO_SET{ETP}
abstract class $SET{ETP} < $RO_SET{ETP} is
-- This abstract class defines the complete set abstraction with
-- reference semantics!
-- Version 1.1 Apr 97. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 1 Jun 96 bg Original
-- 4 Apr 97 kh Changed for style conformity
copy : SAME ;
-- This routine returns a new set which is an identical copy of self.
clear ;
-- This routine deletes all set elements.
as_value : $VSET{ETP} ;
-- This routine returns a value set which contains the values of all
-- of the elements in self.
add(
elem : ETP
) : $VBAG{ETP} ;
-- This routine returns a new bag which contains the values of
-- the elements of self together with the parameter elem.
insert(
elem : ETP
) : $SET{ETP} ;
-- This routine returns a set (which may be a modification of self)
-- containing the elements of self together with the given element elem.
delete(
elem : ETP
) : $SET{ETP} ;
-- This routine returns a set (which may be a modification of self)
-- concontaining all of the elements of self except for one which is element
-- equal to elem (if present).
delete_all(
elem : ETP
) : $SET{ETP} ;
-- This routine returns a set (which may be a modification of self)
-- containing all of the elements of self except for any which are element
-- equal to elem (if present!).
concat(
arg : $ELT{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag containing all of the elements of self
-- and including the given element. For elements that occur multiple times,
-- the result contains the sum of the number of occurences in self and arg.
to_union(
arg : $RO_SET{ETP}
) ;
-- This routine converts self to be the set containing the initial
-- elements in self together with the elements of arg.
union(
arg : $RO_BAG{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag which consists of the union of self
-- and arg. For elements that occur multiple times, the result contains
-- the maximum number of occurences in either self or arg.
--
-- NOTE This definition permits the union of sets to be consistent with
-- the union of bags.
union(
arg : $RO_SET{ETP}
) : $SET{ETP} ;
-- This routine returns a set (which may be a modified version of self)
-- containing all of the elements of self or arg. It overloads the function
-- in $RO_BAG which has an argument and return value of class $RO_BAG.
to_intersection(
arg : $RO_SET{ETP}
) ;
-- This routine converts self into a set which is the intersection of
-- self and arg. This may or may not be a new set.
intersection(
arg : $RO_BAG{ETP}
) : $VBAG{ETP} ;
-- This routine returns a new bag containing only the elements common to
-- both self and arg. For elements that occur multiple times, the result
-- contains the minimum number of occurrences in either self or arg.
intersection(
arg : $RO_SET{ETP}
) : $SET{ETP} ;
-- This routine returns a set (which may or may not be a new set)
-- containing only the elements which are present both in self and in arg.
-- It overloads the function in $RO_BAG which has an argument and return
-- class of $RO_BAG.
to_diff(
arg : $RO_SET{ETP}
) ;
-- This routine converts set to be the set difference of the initial
-- value of self and arg.
diff(
arg : $RO_SET{ETP}
) : $SET{ETP} ;
-- This routine returns the set (which may or may not be a new set)
-- which contains only the elements of self not in arg.
to_sym_diff(
arg : $RO_SET{ETP}
) ;
-- This routine converts set to be the symmetric difference of the
-- initial value of self and arg.
sym_diff(
arg : $RO_SET{ETP}
) : $SET{ETP} ;
-- This routine returns a set (which may or may not be a new set)
-- containing only the elements of self which are not in arg and vice versa.
end ; -- $SET{ETP}