5.3.19.2. Set Operations on Collections without Duplicates
Assume that the example sets are A={a,b}
and B={b,c,d}
. The result of a set operation is another set. The only exception is a subset resulting in a Boolean .true or .false. Using the collection A
and B
, the different set operators produce the following:
- UNION operation
All elements of
A
and
B
are united:
A UNION B = {a,b,c,d}
- DIFFERENCE operation
The resulting collection contains all elements of the first set except for those that also appear in the second set. The system iterates over the elements of the second set and removes them from the first set one by one.
A DIFFERENCE B = {a}
B DIFFERENCE A = {c,d}
- XOR operation
The resulting collection contains all elements of the first set that are not in the second set and all elements of the second set that are not in the first set:
A XOR B = {a,c,d}
- INTERSECTION operation
The resulting collection contains all elements that appear in both sets:
A INTERSECTION B = {b}
- SUBSET operation
Returns
.true
if the first set contains only elements that also appear in the second set, otherwise it returns
.false
:
A SUBSET B = .false
B SUBSET A = .false
- EQUIVALENT operation
Returns
.true
if the first set contains only elements that also appear in the second set and the two sets have the same number of elements, otherwise it returns
.false
:
A EQUIVALENT B = .false
B EQUIVALENT A = .false
- DISJOINT operation
Returns
.true
if there are no elements that appear in both sets, otherwise it returns
.false
:
A DISJOINT B = .false
B DISJOINT A = .false