


Abstract data types 
type 
bitset (in type: baseType) 
 Abstract data type, describing sets of baseType values.  
bitset
const func type: bitset (in type: baseType) 
Abstract data type, describing sets of baseType values.
This abstract data type assumes that baseType values can be
mapped to integer with the ord function.
Sets of integer numbers are described with bitset.
Operator Summary 
setType 
(in setType: set1)  (in setType: set2) 
 Union of two sets.  
setType 
(in setType: set1) & (in setType: set2) 
 Intersection of two sets.  
setType 
(in setType: set1) >< (in setType: set2) 
 Symmetric difference of two sets.  
setType 
(in setType: set1)  (in setType: set2) 
 Difference of two sets.  
void 
(inout setType: dest) := (in setType: delta) 
 Assign the union of delta and dest to dest.  
boolean 
(in setType: set1) = (in setType: set2) 
 Check if two sets are equal.  
boolean 
(in setType: set1) <> (in setType: set2) 
 Check if two sets are not equal.  
boolean 
(in setType: set1) < (in setType: set2) 
 Determine if set1 is a proper subset of set2.  
boolean 
(in setType: set1) > (in setType: set2) 
 Determine if set1 is a proper superset of set2.  
boolean 
(in setType: set1) <= (in setType: set2) 
 Determine if set1 is a subset of set2.  
boolean 
(in setType: set1) >= (in setType: set2) 
 Determine if set1 is a superset of set2.  
boolean 
(in baseType: aValue) in (in setType: aSet) 
 Set membership test.  
boolean 
(in baseType: aValue) not in (in setType: aSet) 
 Negated set membership test.  
void 
(inout setType: aSet) @:= [ (in baseType: aValue) ] (in boolean: isElement) 
 Add or remove aValue to respectively from sSet.  
Function Summary 
integer 
compare (in setType: set1, in setType: set2) 
 Compares two sets to make them useable as key in a hash table.  
integer 
hashCode (in setType: aSet) 
 Compute the hash value of a bitset.  
void 
incl (inout setType: aSet, in baseType: aValue) 
 Add aValue to the set aSet.  
void 
excl (inout setType: aSet, in baseType: aValue) 
 Remove aValue from the set aSet.  
integer 
card (in setType: aSet) 
 Compute the cardinality of a set.  
baseType 
rand (in setType: aSet) 
 Compute pseudorandom number which is element of aSet.  
baseType 
min (in setType: aSet) 
 Minimal element of a set.  
baseType 
max (in setType: aSet) 
 Maximal element of a set.  
void 
for (inout baseType: variable) range (in setType: aSet) do
(in proc: statements)
end for 
 Forloop where variable loops over the elements of the set aSet.  
array baseType 
toArray (in setType: aSet) 
 Obtain an array containing all the values in aSet.  
string 
str (in setType: aSet) 
 Convert a set to a string.  

const func setType: (in setType: set1)  (in setType: set2) 
Union of two sets.
 Returns:
 the union of the two sets.
 Raises:
 MEMORY_ERROR  Not enough memory for the result.
&
const func setType: (in setType: set1) & (in setType: set2) 
Intersection of two sets.
 Returns:
 the intersection of the two sets.
 Raises:
 MEMORY_ERROR  Not enough memory for the result.
><
const func setType: (in setType: set1) >< (in setType: set2) 
Symmetric difference of two sets.
 Returns:
 the symmetric difference of the two sets.
 Raises:
 MEMORY_ERROR  Not enough memory for the result.

const func setType: (in setType: set1)  (in setType: set2) 
Difference of two sets.
 Returns:
 the difference of the two sets.
 Raises:
 MEMORY_ERROR  Not enough memory for the result.
:=
const proc: (inout setType: dest) := (in setType: delta) 
Assign the union of delta and dest to dest.
 Raises:
 MEMORY_ERROR  Not enough memory to create dest.
=
const func boolean: (in setType: set1) = (in setType: set2) 
Check if two sets are equal.
 Returns:
 TRUE if the two sets are equal, FALSE otherwise.
<>
const func boolean: (in setType: set1) <> (in setType: set2) 
Check if two sets are not equal.
 Returns:
 FALSE if the two sets are equal, TRUE otherwise.
<
const func boolean: (in setType: set1) < (in setType: set2) 
Determine if set1 is a proper subset of set2.
set1 is a proper subset of set2 when
set1 <= set2 and set1 <> set2
holds.
 Returns:
 TRUE if set1 is a proper subset of set2, FALSE otherwise.
>
const func boolean: (in setType: set1) > (in setType: set2) 
Determine if set1 is a proper superset of set2.
set1 is a proper superset of set2 when
set1 >= set2 and set1 <> set2
holds.
 Returns:
 TRUE if set1 is a proper superset of set2, FALSE otherwise.
<=
const func boolean: (in setType: set1) <= (in setType: set2) 
Determine if set1 is a subset of set2.
set1 is a subset of set2 when no element X exists for which
X in set1 and X not in set2
holds.
 Returns:
 TRUE if set1 is a subset of set2, FALSE otherwise.
>=
const func boolean: (in setType: set1) >= (in setType: set2) 
Determine if set1 is a superset of set2.
set1 is a superset of set2 when no element X exists for which
X in set2 and X not in set1
holds.
 Returns:
 TRUE if set1 is a superset of set2, FALSE otherwise.
in
const func boolean: (in baseType: aValue) in (in setType: aSet) 
Set membership test.
Determine if aValue is a member of the set aSet.
 Returns:
 TRUE when aValue is a member of aSet, FALSE otherwise.
not in
const func boolean: (in baseType: aValue) not in (in setType: aSet) 
Negated set membership test.
Determine if aValue is not a member of the set aSet.
 Returns:
 FALSE when aValue is a member of aSet, TRUE otherwise.
@:= [
const proc: (inout setType: aSet) @:= [ (in baseType: aValue) ] (in boolean: isElement) 
Add or remove aValue to respectively from sSet.
Adding an existing value or remove a nonexisting value
leaves aSet unchanged.
 Raises:
 MEMORY_ERROR  When there is not enough memory.
compare
const func integer: compare (in setType: set1, in setType: set2) 
Compares two sets to make them useable as key in a hash table.
The sets are compared by determining the biggest element that is
not present or absent in both sets. The set in which this element
is not present is the smaller one. Note that the set comparison
is not related to the concepts of subset or superset. With the
comparison function compare it is posible to sort an array of
sets or to use sets as key in a hash table.
 Returns:
 1, 0 or 1 if the first argument is considered to be respectively less than, equal to, or greater than the second.
hashCode
const func integer: hashCode (in setType: aSet) 
Compute the hash value of a bitset.
 Returns:
 the hash value.
incl
const proc: incl (inout setType: aSet, in baseType: aValue) 
Add aValue to the set aSet.
When aValue is already in aSet then aSet stays unchanged.
 Raises:
 MEMORY_ERROR  When there is not enough memory.
excl
const proc: excl (inout setType: aSet, in baseType: aValue) 
Remove aValue from the set aSet.
When aValue is not element of aSet then aSet stays unchanged.
card
const func integer: card (in setType: aSet) 
Compute the cardinality of a set.
 Returns:
 the number of elements in aSet.
rand
const func baseType: rand (in setType: aSet) 
Compute pseudorandom number which is element of aSet.
The random values are uniform distributed.
 Returns:
 a random number such that rand(aSet) in aSet holds.
 Raises:
 RANGE_ERROR  When aSet is empty.
min
const func baseType: min (in setType: aSet) 
Minimal element of a set.
Delivers the element from aSet for which the following condition holds:
element <= X
for all X which are in the set.
 Returns:
 the minimum element of aSet.
 Raises:
 RANGE_ERROR  When aSet is the empty set.
max
const func baseType: max (in setType: aSet) 
Maximal element of a set.
Delivers the element from aSet for which the following condition holds:
element >= X
for all X which are in the set.
 Returns:
 the maximal element of aSet.
 Raises:
 RANGE_ERROR  When aSet is the empty set.
for
const proc: for (inout baseType: variable) range (in setType: aSet) do
(in proc: statements)
end for 
Forloop where variable loops over the elements of the set aSet.
toArray
const func array baseType: toArray (in setType: aSet) 
Obtain an array containing all the values in aSet.
 Returns:
 all the values from aSet.
str
const func string: str (in setType: aSet) 
Convert a set to a string.
 Returns:
 the string result of the conversion.
 Raises:
 MEMORY_ERROR  Not enough memory to represent the result.


