Libraries |
|
Bitset | Source Code |
|
|
Operator Summary | |||||
bitset |
| ||||
bitset |
| ||||
bitset |
| ||||
bitset |
| ||||
bitset |
| ||||
void |
| ||||
void |
| ||||
void |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
boolean |
| ||||
void |
| ||||
bitset |
| ||||
bitset |
| ||||
bitset |
| ||||
integer |
| ||||
bitset |
| ||||
bitset |
|
Function Summary | |||||
integer |
| ||||
integer |
| ||||
void |
| ||||
void |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
integer |
| ||||
bitset |
| ||||
void |
| ||||
array integer |
| ||||
string |
| ||||
bitset |
|
Operator Detail |
|
const func bitset: (in bitset: set1) | (in bitset: set2)
-
Union of two sets.
{1, 2} | {1, 3} returns {1, 2, 3}
- Returns:
- the union of the two sets.
- Raises:
- MEMORY_ERROR - Not enough memory for the result.
&
const func bitset: (in bitset: set1) & (in bitset: set2)
-
Intersection of two sets.
{1, 2} & {1, 3} returns {1}
- Returns:
- the intersection of the two sets.
- Raises:
- MEMORY_ERROR - Not enough memory for the result.
><
const func bitset: (in bitset: set1) >< (in bitset: set2)
-
Symmetric difference of two sets.
{1, 2} >< {1, 3} returns {2, 3}
- Returns:
- the symmetric difference of the two sets.
- Raises:
- MEMORY_ERROR - Not enough memory for the result.
-
const func bitset: (in bitset: set1) - (in bitset: set2)
-
Difference of two sets.
{1, 2} - {1, 3} returns {2}
- Returns:
- the difference of the two sets.
- Raises:
- MEMORY_ERROR - Not enough memory for the result.
|:=
const proc: (inout bitset: dest) |:= (in bitset: set2)
-
Assign the union of dest and set2 to dest.
- Raises:
- MEMORY_ERROR - Not enough memory to create dest.
&:=
const proc: (inout bitset: dest) &:= (in bitset: set2)
-
Assign the intersection of dest and set2 to dest.
- Raises:
- MEMORY_ERROR - Not enough memory to create dest.
-:=
const proc: (inout bitset: dest) -:= (in bitset: set2)
-
Assign the difference of dest and set2 to dest.
- Raises:
- MEMORY_ERROR - Not enough memory to create dest.
=
const func boolean: (in bitset: set1) = (in bitset: set2)
-
Check if two sets are equal.
- Returns:
- TRUE if the two sets are equal, FALSE otherwise.
<>
const func boolean: (in bitset: set1) <> (in bitset: set2)
-
Check if two sets are not equal.
- Returns:
- FALSE if the two sets are equal, TRUE otherwise.
<
const func boolean: (in bitset: set1) < (in bitset: set2)
-
Determine if set1 is a proper subset of set2. set1 is a proper subset of set2 if
set1 <= set2 and set1 <> set2
holds.
- Returns:
- TRUE if set1 is a proper subset of set2, FALSE otherwise.
>
const func boolean: (in bitset: set1) > (in bitset: set2)
-
Determine if set1 is a proper superset of set2. set1 is a proper superset of set2 if
set1 >= set2 and set1 <> set2
holds.
- Returns:
- TRUE if set1 is a proper superset of set2, FALSE otherwise.
<=
const func boolean: (in bitset: set1) <= (in bitset: set2)
-
Determine if set1 is a subset of set2. set1 is a subset of set2 if 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 bitset: set1) >= (in bitset: set2)
-
Determine if set1 is a superset of set2. set1 is a superset of set2 if 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 integer: number) in (in bitset: aSet)
-
Set membership test. Determine if number is a member of the set aSet.
2 in {2, 3, 5, 7} returns TRUE 4 in {2, 3, 5, 7} returns FALSE
- Returns:
- TRUE if number is a member of aSet, FALSE otherwise.
not in
const func boolean: (in integer: number) not in (in bitset: aSet)
-
Negated set membership test. Determine if number is not a member of the set aSet.
2 not in {2, 3, 5, 7} returns FALSE 4 not in {2, 3, 5, 7} returns TRUE
- Returns:
- FALSE if number is a member of aSet, TRUE otherwise.
@:= [
const proc: (inout bitset: aSet) @:= [ (in integer: number) ] (in boolean: isElement)
-
Add or remove aValue to respectively from sSet. Adding an existing value or remove a non-existing value leaves aSet unchanged.
- Raises:
- MEMORY_ERROR - If there is not enough memory.
{
const func bitset: { (in integer: aNumber) }
-
Create bitset with the element aNumber.
{42} returns a bitset with the element 42.
{
const func bitset: { (in tuple integer: numberTuple) }
-
Create bitset with elements from a comma separated list.
{2, 3, 5, 7, 11} returns a bitset with the elements 2, 3, 5, 7 and 11.
{
const func bitset: { (in integer: lowValue) .. (in integer: highValue) }
-
Create bitset with all elements from lowValue to highValue inclusive.
{1 .. 5} returns a bitset with the elements 1, 2, 3, 4 and 5.
conv
const func integer: (attr integer) conv (in bitset: aSet)
conv
const func bitset: (attr bitset) conv (in integer: number)
parse
const func bitset: (attr bitset) parse (in string: stri)
-
Convert a string to a bitset.
- Returns:
- the integer result of the conversion.
- Raises:
- RANGE_ERROR - If the string is empty or cannot be converted to a bitset.
Function Detail |
compare
const func integer: compare (in bitset: set1, in bitset: 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 possible 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 bitset: aSet)
-
Compute the hash value of a bitset.
- Returns:
- the hash value.
incl
const proc: incl (inout bitset: aSet, in integer: number)
-
Add number to the set aSet. If number is already in aSet then aSet stays unchanged.
- Raises:
- MEMORY_ERROR - If there is not enough memory.
excl
const proc: excl (inout bitset: aSet, in integer: number)
-
Remove number from the set aSet. If number is not element of aSet then aSet stays unchanged.
card
const func integer: card (in bitset: aSet)
-
Compute the cardinality of a set.
card({2, 3, 5, 7, 11}) returns 5 card(EMPTY_SET) returns 0
- Returns:
- the number of elements in aSet.
- Raises:
- RANGE_ERROR - Result does not fit into an integer.
rand
const func integer: rand (in bitset: aSet)
-
Compute pseudo-random element from aSet. The random values are uniform distributed.
rand(EMPTY_SET) raises RANGE_ERROR
- Returns:
- a random number such that rand(aSet) in aSet holds.
- Raises:
- RANGE_ERROR - If aSet is empty.
min
const func integer: min (in bitset: aSet)
-
Minimum 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.
min({2, 3, 5, 7, 11}) returns 2 min(EMPTY_SET) raises RANGE_ERROR
- Returns:
- the minimum element of aSet.
- Raises:
- RANGE_ERROR - If aSet is the empty set.
max
const func integer: max (in bitset: aSet)
-
Maximum 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.
max({2, 3, 5, 7, 11}) returns 11 max(EMPTY_SET) raises RANGE_ERROR
- Returns:
- the maximum element of aSet.
- Raises:
- RANGE_ERROR - If aSet is the empty set.
next
const func integer: next (in bitset: aSet, in integer: number)
-
Minimum element of aSet that is larger than number.
next({2, 3, 5, 7, 11}, 2) returns 3 next({2, 3, 5, 7, 11}, 3) returns 5 next({2, 3, 5, 7, 11}, 7) returns 11 next({2, 3, 5, 7, 11}, 11) raises RANGE_ERROR next({}, 1) raises RANGE_ERROR
- Returns:
- the minimum element of aSet that is larger than number.
- Raises:
- RANGE_ERROR - If aSet has no element larger than number.
integer
const func integer: integer (in bitset: aSet)
bitset
const func bitset: bitset (in integer: number)
for
const proc: for (inout integer: forVar) range (in bitset: aSet) do (in proc: statements) end for
-
For-loop where forVar loops over the elements of the set aSet.
toArray
const func array integer: toArray (in bitset: aSet)
-
Obtain an array containing all the values in aSet.
toArray({2, 3, 5}) returns [](2, 3, 5)
- Returns:
- all the values from aSet.
str
const func string: str (in bitset: aSet)
-
Convert a bitset to a string.
str({}) returns "{}" str({1, 2}) returns "{1, 2}"
- Returns:
- the string result of the conversion.
- Raises:
- MEMORY_ERROR - Not enough memory to represent the result.
bitset
const func bitset: bitset (in var string: stri)
-
Convert a string to a bitset.
bitset("{}") returns {}, bitset("{2, 3, 5, 7}") returns {2, 3, 5, 7} )
- Returns:
- a bitset which corresponds to the given literal.
- Raises:
- RANGE_ERROR - If the string is empty or cannot be converted to a bitset.
|
|