multimap.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_MULTIMAP{KEY,ETP} < $RO_BAG{TUP{KEY,ETP}}
abstract class $RO_MULTIMAP{KEY,ETP} < $RO_BAG{TUP{KEY,ETP}} is
-- This abstract class provides a mapping from a key to a bag of
-- elements. It binds elements of class ETP to keys of class KEY. This is
-- a one-to-many mapping.
-- Version 1.3 Nov 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 1 Jun 94 hk Original
-- 1 Jun 96 bg Amended for Sather 1.1
-- 4 Apr 97 kh Changed for INT to CARD
-- 9 Nov 98 kh Revised for 1.2
has_ind(
key : KEY
) : BOOL ;
-- This routine returns true if and only if the map contains an element
-- mapped by the given key.
n_ind : CARD ;
-- This returns the number of unique keys which are bound.
n_targets(
key : KEY
) : CARD ;
-- This routine returns the number of elements bound to the given key.
has(
key : KEY,
elem : ETP
) : BOOL ;
-- This feature returns true if and only if the map contains an element
-- equal to the elem argument which is mapped by the given key.
add(
elem : TUP{KEY,ETP}
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap containaing, in addition to all
-- of the elements of self, the new element given.
add(
key : KEY,
elem : ETP
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine is identical to the above with the two separate
-- arguments rather than the tuple!
delete(
elem : TUP{KEY,ETP}
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine returns a new map identical to self except for one
-- element which is element equal to elem (if such an one exists).
delete(
key : KEY,
elem : ETP
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine is identical to the above with the two separate
-- arguments rather than the tuple!
delete_ind(
key : KEY
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine returns a new map from which any occurrences of the key
-- (and its target) have been deleted.
delete_all(
elem : TUP{KEY,ETP}
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine returns a new map identical to self except for all
-- elements which are equal to self (if any).
concat(
arg : $ELT{TUP{KEY,ETP}}
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap consisting of the elements of
-- self together with those of arg. For elements which occur multiple times
-- then the result contains the sum of the number in self and the number in
-- arg.
union(
arg : $RO_BAG{TUP{KEY,ETP}}
) : $RO_MULTIMAP{KEY,ETP} ;
-- This returns a multimap containing all of the elements of self and
-- arg. For those elements which occur multiple times the number in the map
-- returned is the larger of the numbers in self and arg.
intersection(
arg : $RO_BAG{TUP{KEY,ETP}}
) : $RO_MULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap containing the elements common
-- to self and arg. For elements which occur multiple times the result
-- contains the lower number of occurrences in self an arg.
ind! : KEY ;
-- This iter yields all indices which are bound in an arbitrary order.
target!(
once key : KEY
) : ETP ;
-- This iter yields all elements of the map which are bound to the given
-- key in an arbitrary order.
pair! : TUP{KEY,ETP} ;
-- This iter yields all bindings in the multimap in an arbitrary order.
end ; -- $RO_MULTIMAP
abstract class $VMULTIMAP{KEY,ETP} < $RO_MULTIMAP{KEY,ETP},
abstract class $VMULTIMAP{KEY,ETP} < $RO_MULTIMAP{KEY,ETP},
$VBAG{TUP{KEY,ETP}} is
-- This abstraction models an unordered container of tuples of key
-- and element such that the indices of all tuples are unique. Indices may
-- be used to retrieve targets
--
-- IMPORTANT This is a 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 Nov 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 1 Sep 96 bg New for Sather 1.2
-- 9 Nov 98 kh Revised for compatibility.
add(
elem : TUP{KEY,ETP}
) : $VMULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap containaing, in addition to all
-- of the elements of self, the new element given.
add(
key : KEY,
elem : ETP
) : $VMULTIMAP{KEY,ETP} ;
-- This routine is identical to the above with the two separate
-- arguments rather than the tuple!
delete(
elem : TUP{KEY,ETP}
) : $VMULTIMAP{KEY,ETP} ;
-- This routine returns a new map identical to self except for one
-- element which is element equal to elem (if such an one exists).
delete(
key : KEY,
elem : ETP
) : $VMULTIMAP{KEY,ETP} ;
-- This routine is identical to the above with the two separate
-- arguments rather than the tuple!
delete_ind(
key : KEY
) : $VMULTIMAP{KEY,ETP} ;
-- This routine returns a new map from which any occurrences of the key
-- (and its target) have been deleted.
delete_all(
elem : TUP{KEY,ETP}
) : $VMULTIMAP{KEY,ETP} ;
-- This routine returns a new map identical to self except for all
-- elements which are equal to self (if any).
concat(
arg : $ELT{TUP{KEY,ETP}}
) : $VMULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap consisting of the elements of
-- self together with those of arg. For elements which occur multiple times
-- then the result contains the sum of the number in self and the number in
-- arg.
union(
arg : $RO_BAG{TUP{KEY,ETP}}
) : $VMULTIMAP{KEY,ETP} ;
-- This returns a multimap containing all of the elements of self and
-- arg. For those elements which occur multiple times the number in the map
-- returned is the larger of the numbers in self and arg.
intersection(
arg : $RO_BAG{TUP{KEY,ETP}}
) : $VMULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap containing the elements common
-- to self and arg. For elements which occur multiple times the result
-- contains the lower number of occurrences in self an arg.
end ; -- $VMULTIMAP
abstract class $MULTIMAP{KEY,ETP} < $RO_MULTIMAP{KEY,ETP}
abstract class $MULTIMAP{KEY,ETP} < $RO_MULTIMAP{KEY,ETP} is
-- This abstract class models a modifiable multimap.
-- Version 1.3 Nov 98. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 1 Jun 94 hk Original
-- 1 Jun 96 bg Amended for Sather 1.1
-- 4 Apr 97 kh Changed for INT to CARD
-- 9 Nov 98 kh Revised for 1.2.
as_value : $VMULTIMAP{KEY,ETP} ;
-- This routine returns a new map containing the value associated with
-- self.
clear ;
-- This routine deletes all elements from self - which is then empty.
aset(
key : KEY,
elem : ETP
) ;
-- This routine binds the given element to the key provided.
delete(
key : KEY,
elem : ETP
) ;
-- This routine removes the binding between elem and key from the map.
-- If there is nos such binding then it does nothing!
delete(
key : KEY
) ;
-- This routine removes all bindings associated with the given key. If
-- there are no such bindings then nothing is done.
to_union(
arg : $RO_MULTIMAP{KEY,ETP}
) ;
-- This routine makes self the union of the initial value of self and
-- the value of arg.
to_intersection(
arg : $RO_MULTIMAP{KEY,ETP}
) ;
-- This routine makes self the intersection of the initial value of self
-- and the value of arg.
add(
elem : TUP{KEY,ETP}
) : $MULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap containaing, in addition to all
-- of the elements of self, the new element given.
add(
key : KEY,
elem : ETP
) : $MULTIMAP{KEY,ETP} ;
-- This routine is identical to the above with the two separate
-- arguments rather than the tuple!
delete(
elem : TUP{KEY,ETP}
) : $MULTIMAP{KEY,ETP} ;
-- This routine returns a new map identical to self except for one
-- element which is element equal to elem (if such an one exists).
delete(
key : KEY,
elem : ETP
) : $MULTIMAP{KEY,ETP} ;
-- This routine is identical to the above with the two separate
-- arguments rather than the tuple!
delete_ind(
key : KEY
) : $MULTIMAP{KEY,ETP} ;
-- This routine returns a new map from which any occurrences of the key
-- (and its target) have been deleted.
delete_all(
elem : TUP{KEY,ETP}
) : $MULTIMAP{KEY,ETP} ;
-- This routine returns a new map identical to self except for all
-- elements which are equal to self (if any).
concat(
arg : $RO_BAG{TUP{KEY,ETP}}
) : $MULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap consisting of the elements of
-- self together with those of arg. For elements which occur multiple times
-- then the result contains the sum of the number in self and the number in
-- arg.
union(
arg : $RO_BAG{TUP{KEY,ETP}}
) : $MULTIMAP{KEY,ETP} ;
-- This returns a multimap containing all of the elements of self and
-- arg. For those elements which occur multiple times the number in the map
-- returned is the larger of the numbers in self and arg.
intersection(
arg : $RO_BAG{TUP{KEY,ETP}}
) : $MULTIMAP{KEY,ETP} ;
-- This routine returns a new multimap containing the elements common
-- to self and arg. For elements which occur multiple times the result
-- contains the lower number of occurrences in self an arg.
end ; -- $MULTIMAP{KEY,ETP}