Other generic algorithms – HP Integrity NonStop H-Series User Manual
Page 90
![background image](/manuals/396950/90/background.png)
while the merge will contain five. To form the merge, the function merge() can be used (see
). The arguments to this function exactly match those of the
set_union() function.
Set Difference
There are two forms of set difference. A simple set difference represents the elements in the first set
that are not contained in the second. A symmetric set difference is the union of the elements in the
first set that are not contained in the second, with the elements in the second that are not contained
in the first. These two values are constructed by the functions set_difference() and
set_symmetric_difference(), respectively. The use of these functions is similar to the use of the
set_union() function described earlier.
Other Generic Algorithms
Because sets are ordered and have constant iterators, a number of the generic functions described in
Chapters
either are not applicable to sets or are not particularly useful. However, the
following table gives a few of the functions that can be used in conjunction with the
set
data type.
Purpose
Name
Chapter / Section
Copy one sequence into another
copy
Copy One Sequence into Another
Find an element that matches a condition
find_if
Find a subsequence within a set
search
Find a Subsequence within a Sequence
Count number of elements that satisfy
condition
count_if
Count the Number of Elements...
Reduce set to a single value
accumulate
Reduce Sequence to a Single Value
Execute function on each element
for_each
Apply a Function to All Elements in a