abstract class $MAP{ITP,TTP} < $RO_MAP{ITP,TTP}, $VAR |
---|
**** | An unordered container of tuples of {index:ITP,target:TTP} such that the indices of all tuples are unique. Indices may be used to retrieve targets
_ This is a reference abstraction and supports operations that modify self. Instances of subtypes may be viewed as variables with a value of $VMULTIMAP{ITP,TTP} _ For pointers to other documentation please see the class comment in the read-only abstraction $RO_MAP{ITP,TTP} |
$VAR | $RO_MAP{_,_} | $RO_MULTIMAP{_,_} | $RO_BAG{_} | $CONTAINER{_} | $STR | $ELT{_} | $ELT |
MAP{_,_} |
add(k:ITP,e:TTP):$VMULTIMAP{ITP,TTP}; |
---|
**** | Shortcut for for add(#TUP{ITP,TTP}(k,e)) |
add(e:TUP{ITP,TTP}):$VMULTIMAP{ITP,TTP}; |
---|
**** | Result is a new bag containing all the elements of self and 'e' |
aget(k:ITP):TTP; |
---|
**** | Returns the element k is mapped to.
_ result is e s.t. self has (k,e). If self has no (k,_) then __________result_is_undefined |
as_array:ARRAY{TUP{ITP,TTP}}; |
---|
**** | Return the elements of the container in an array |
as_value:$VMAP{ITP,TTP}; |
---|
**** | Return the current value associated with self |
aset(k:ITP,e:TTP); |
---|
**** | Maps k to e. If k is already mapped, replace the old maping with the new one. |
concat(arg:$RO_BAG{TUP{ITP,TTP}}):$VMULTIMAP{ITP,TTP}; |
---|
**** | Returns a bag containing all the elements of self and 'arg'. For elements that occur multiple times, the result contains the sum of the number of occurences in self and 'arg'
_ result=mmap of all e s.t. result.count(e)=self.count(e)+arg.count(e) |
copy: SAME; |
---|
**** | Return a copy of the current container |
count(e:TUP{ITP,TTP}):INT; |
---|
**** | Return the number of occurences of 'e' in self |
delete(k:ITP); |
---|
**** | Delete the tuple associated with element "k". Does nothing if no tuple was associated with "k" |
delete(k:ITP,e:TTP):$MAP{ITP,TTP}; |
---|
**** | Shortcut for for delete(e:TUP{ITP,TTP}) |
delete(e:TUP{ITP,TTP}):$MAP{ITP,TTP}; |
---|
**** | Result is a new multimap containing all the elements of self except for an element equal to 'e', if one exists. If more than one element is equal to 'e', delete only one of them |
delete_all(e:TUP{ITP,TTP}):$MAP{ITP,TTP}; |
---|
**** | Result is a new multimap containing all the elements of self except for all elements equal to 'e', if any exist. Same as 'delete' here |
delete_ind(k:ITP):$MAP{ITP,TTP}; |
---|
**** | Returns a new multimap in which all occurences of the tuple (k,_) have been deleted |
diff(arg:$RO_MAP{ITP,TTP}):$MAP{ITP,TTP}; |
---|
**** | Returns a map containing the elements common to self and 'arg'
_ result=map of all e s.t. self.has(e) and ~arg.has(e) |
elt!:TUP{ITP,TTP}; |
---|
**** | Yield all the elements of self. The order is not defined. |
equals(c:$RO_BAG{TUP{ITP,TTP}}):BOOL; |
---|
**** | Return true if both containers contain the same elements with the same number of repetitions, irrespective of the order of the elements |
has(e: TUP{ITP,TTP}): BOOL; |
---|
**** | True if the container contains the element "e" |
has_ind(k:ITP): BOOL; |
---|
**** | Returns true if this map has an index equal to 'k'
_ result is true iff self contains a tuple (k,_) |
ind!:ITP; |
---|
**** | Yields all the indices of self i.e. first elements of every tuple in self, in an unspecified order
_ yield all i s.t. self.has((i,_)) |
insert(k:ITP,e:TTP):$MAP{ITP,TTP}; |
---|
**** | Shortcut for for add(#TUP{ITP,TTP}(k,e)) |
insert(e:TUP{ITP,TTP}):$MAP{ITP,TTP}; |
---|
**** | Insert the element 'e' in the bag. If a tuple (e.t1,_) exists, the replace it with (e.t1,e.t2) |
intersection(arg: $RO_BAG{TUP{ITP,TTP}}): $VMULTIMAP{ITP,TTP}; |
---|
**** | Returns a bag containing the elements common to self and 'arg' For elements that occur multiple times, the result contains the minimum number of occurrences in either self or 'arg'
_ result=bag of all e s.t. ______________result.count(e)=min(self.count(e),arg.count(e))_>_0 |
intersection(arg: $RO_MAP{ITP,TTP}):$MAP{ITP,TTP}; |
---|
**** | Returns a map containing the elements common to self and 'arg' Overloads the version in $RO_BAG which has an argument and return type of $RO_BAG
_ result=map of all e s.t. self.has(e) and arg.has(e) |
is_empty:BOOL; |
---|
**** | Returns true if the size of the container = 0 |
is_subset_of(arg: $RO_BAG{TUP{ITP,TTP}}): BOOL; |
---|
**** | Returns true if 'self' is a subset of 'arg'. For elements that occur multiple times, the number of occurences of the element in 'arg' must be greater than or equal to the number of occurences in self
_ result=true iff for all e in self: count(e) <= arg.count(e) |
n_targets(k:ITP): INT; |
---|
**** | Returns the number of targets associated with the index 'k' i.e. 0 or 1 |
n_unique: INT; |
---|
**** | Returns the number of unique elements in the bag
_ result = number of unique elements |
pair!: TUP{ITP,TTP}; |
---|
**** | Yields all elements of self in an unspecified order. An alias for "elt!" |
size: INT; |
---|
**** | Number of elements contained |
str:STR; |
---|
**** | Yield a string version of self |
sym_diff(arg:$RO_MAP{ITP,TTP}):$MAP{ITP,TTP}; |
---|
**** | Returns a map containing the elements not common to self and 'arg'
_ result=map of all e s.t. self.has(e) xor arg.has(e) |
target!:TTP; |
---|
**** | Yields all the targets in this mapping in an unspecified order
_ yield all t s.t. self has (_,t) |
target!(once k:ITP):TTP; |
---|
**** | Yields all the target associated with index 'k'
_ yield all t s.t. self.has((k,t)) |
to_diff(arg:$RO_MAP{ITP,TTP}); |
---|
**** | Turn this bag into the difference of self and 'arg' self <- initial(self).diff(arg) |
to_intersection(arg:$RO_MAP{ITP,TTP}); |
---|
**** | Turn this bag into the intersection of self and 'arg' self <- initial(self).intersection(arg) |
to_sym_diff(arg:$RO_BAG{TUP{ITP,TTP}}); |
---|
**** | Turn this bag into the symmetric difference of self and 'arg' self <- initial(self).sym_diff(arg) |
to_union(arg: $RO_MAP{ITP,TTP}); |
---|
**** | Turn this bag into the union of self and 'arg' self <- initial(self).union(arg) |
union(arg: $RO_BAG{TUP{ITP,TTP}}): $VMULTIMAP{ITP,TTP}; |
---|
**** | Returns a bag containing the elements of 'self' and 'arg'. For elements that occur multiple times, the result contains the maximum number of occurences in either self or 'arg'
_ result=bag of all e s.t. _____________result.count(e)=_max(self.count(e),arg.count(e))_>_0 |
union(arg: $RO_MAP{ITP,TTP}): $MAP{ITP,TTP}; |
---|
**** | Returns a map containing the elements of 'self' and 'arg'.
_ result=map of all e s.t. self.has(e) or arg.has(e) |
unique!:TUP{ITP,TTP}; |
---|
**** | Yield the unique elements of self. Equivalent to self.as_set.elt! |