set_symmetric_difference man page on SunOS

Man page or keyword search:  
man Server   20652 pages
apropos Keyword Search (all sections)
Output format
SunOS logo
[printable version]

set_symmetric_difference(3C++)	       -	set_symmetric_difference(3C++)

Standard C++ Library Copyright 1998, Rogue Wave Software, Inc.

NAME
       set_symmetric_difference

	-  A  basic  set operation for constructing a sorted symmetric differ‐
       ence.

SYNOPSIS
       #include <algorithm>
       template <class InputIterator1, class InputIterator2,
	 class OutputIterator>
 OutputIterator
    set_symmetric_difference (InputIterator1 first1,
			     InputIterator1 last1,
			     InputIterator2 first2,
			     InputIterator2 last2,
			     OutputIterator result);
template <;class InputIterator1, class InputIterator2,
	 class OutputIterator, class Compare>
 OutputIterator
    set_symmetric_difference (InputIterator1 first1,
			     InputIterator1 last1,
			     InputIterator2 first2,
			     InputIterator2 last2,
			     OutputIterator result,
			     Compare comp);

DESCRIPTION
       set_symmetric_difference constructs a sorted  symmetric	difference  of
       the elements from the two ranges. This means that the constructed range
       includes copies of the elements that are present in the range  [first1,
       last1) (but not present in the range [first2, last2)) and copies of the
       elements that are present in the range [first2, last2) (but not in  the
       range [first1, last1)). It returns the end of the constructed range.

       For example, suppose we have two sets:

       1 2 3 4 5

       and

       3 4 5 6 7

       The set_symmetric_difference of these two sets is:

       1 2 6 7

       The result of set_symmetric_difference is undefined if the result range
       overlaps with either of the original ranges.

       set_symmetric_difference assumes that the ranges are sorted  using  the
       default	comparison  operator less than (<), unless an alternative com‐
       parison operator (comp) is provided.

       Use the set_symmetric_difference algorithm  to  return  a  result  that
       includes elements that are present in the first set and not in the sec‐
       ond.

COMPLEXITY
       At most ((last1 - first1) + (last2 - first2)) * 2  -1  comparisons  are
       performed.

EXAMPLE
//
// set_s_di.cpp
//
#include<algorithm>
#include<set>
#include <istream.h>
using namespace std;

int main()
 {

//Initialize some sets
int a1[] = {1,3,5,7,9,11};
int a3[] = {3,5,7,8};
set<;int, less<int> > odd(a1+0,a1+6), result,
   small(a3+0,a3+4);
//Create an insert_iterator for result
insert_iterator<;set<int, less<int> > >
   res_ins(result, result.begin());
//Demonstrate set_symmetric_difference
cout <;< "The symmetric difference of:" << endl << "{";
copy(small.begin(),small.end(),
    ostream_iterator<int,char>(cout," "));
cout <;< "} with {";
copy(odd.begin(),odd.end(),
    ostream_iterator<int,char>(cout," "));
cout <;< "} =" << endl << "{";
set_symmetric_difference(small.begin(), small.end(),
			odd.begin(), odd.end(), res_ins);
copy(result.begin(),result.end(),
    ostream_iterator<int,char>(cout," "));
cout <;< "}" << endl << endl;
return 0;
 }

Program Output

The symmetric difference of:
{3 5 7 8 } with {1 3 5 7 9 11 } =
{1 8 9 11 }

WARNINGS
       If your compiler does not support default template parameters, then you
       always need to supply the Compare template argument and	the  Allocator
       template argument. For instance, you need to write:

       set<int, less<int>, allocator<int> >

       instead of:

       set<int>

       If  your compiler does not support namespaces, then you do not need the
       using declaration for std.

SEE ALSO
       includes, set, set_union, set_intersection, set_difference

Rogue Wave Software		  02 Apr 1998	set_symmetric_difference(3C++)
[top]

List of man pages available for SunOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net