.\" ident @(#)set_symmetric_difference.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH set_symmetric_difference 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2set_symmetric_difference\fP \ - A basic set operation for constructing a sorted symmetric difference. .SH SYNOPSIS .br #include .br template .RE .RS 1 OutputIterator .RE .RS 0 set_symmetric_difference (InputIterator1 first1, .RE .RS 29 InputIterator1 last1, .br InputIterator2 first2, .br InputIterator2 last2, .br OutputIterator result); .RE .RS 0 template .RE .RS 1 OutputIterator .RE .RS 0 set_symmetric_difference (InputIterator1 first1, .RE .RS 29 InputIterator1 last1, .br InputIterator2 first2, .br InputIterator2 last2, .br OutputIterator result, .br Compare comp); .SH 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 \f2[first1, last1)\fP (but not present in the range \f2[first2, last2)\fP) and copies of the elements that are present in the range \f2[first2, last2)\fP (but not in the range \f2[first1, last1)\fP). It returns the end of the constructed range. For example, suppose we have two sets: \f21 2 3 4 5\fP and \f23 4 5 6 7\fP The set_symmetric_difference of these two sets is: \f21 2 6 7\fP 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 (\f2<\fP), unless an alternative comparison operator (\f2comp\fP) 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 second. .SH COMPLEXITY At most \f2((last1 - first1) + (last2 - first2)) * 2 -1\fP comparisons are performed. .SH EXAMPLE .RE .RS 0 // .br // set_s_di.cpp .br // .br #include .br #include .br #include .br using namespace std; .br .br int main() .RE .RS 1 { .RE .RS 0 .br //Initialize some sets .br int a1[] = {1,3,5,7,9,11}; .br int a3[] = {3,5,7,8}; .br set > odd(a1+0,a1+6), result, .RE .RS 3 small(a3+0,a3+4); .RE .RS 0 //Create an insert_iterator for result .br insert_iterator > > .RE .RS 3 res_ins(result, result.begin()); .RE .RS 0 //Demonstrate set_symmetric_difference .br cout << "The symmetric difference of:" << endl << "{"; .br copy(small.begin(),small.end(), .RE .RS 4 ostream_iterator(cout," ")); .RE .RS 0 cout << "} with {"; .br copy(odd.begin(),odd.end(), .RE .RS 4 ostream_iterator(cout," ")); .RE .RS 0 cout << "} =" << endl << "{"; .br set_symmetric_difference(small.begin(), small.end(), .RE .RS 24 odd.begin(), odd.end(), res_ins); .RE .RS 0 copy(result.begin(),result.end(), .RE .RS 4 ostream_iterator(cout," ")); .RE .RS 0 cout << "}" << endl << endl; .br return 0; .RE .RS 1 } .RE .RS 0 .br .RE .RS 0 Program Output .br .br The symmetric difference of: .br {3 5 7 8 } with {1 3 5 7 9 11 } = .br {1 8 9 11 } .SH WARNINGS If your compiler does not support default template parameters, then you always need to supply the \f2Compare\fP template argument and the \f2Allocator\fP template argument. For instance, you need to write: \f2set, allocator >\fP instead of: \f2set\fP If your compiler does not support namespaces, then you do not need the using declaration for \f2std\fP. .SH SEE ALSO includes, set, set_union,_set_intersection, set_difference