Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
set_sym_diff.cpp
Go to the documentation of this file.
1
29#include <algorithm> // for copy, set_symmetric_difference
30#include <set> // for set
31#include <iostream> // for cout, endl
32#include <iterator> // for ostream_iterator
33
34int main ()
35{
36 // Initialize some sets.
37 const int a1[] = { 1, 3, 5, 7, 9, 11 };
38 const int a3[] = { 3, 5, 7, 8 };
39
40 std::set<int, std::less<int>, std::allocator<int> >
41 odd (a1 + 0, a1 + 6),
42 result,
43 smalll (a3 + 0, a3 + 4);
44
45 // Create an insert_iterator for result.
46 std::insert_iterator<std::set<int, std::less<int>, std::allocator<int> > >
47 res_ins (result, result.begin ());
48
49 // Demonstrate set_symmetric_difference.
50
51 typedef std::ostream_iterator<int, char, std::char_traits<char> > Iter;
52
53 std::cout << "The symmetric difference of:\n{";
54
55 std::copy (smalll.begin (), smalll.end (), Iter (std::cout, " "));
56 std::cout << "} with {";
57
58 std::copy (odd.begin (),odd.end (), Iter (std::cout, " "));
59 std::cout << "} =\n{";
60
61 std::set_symmetric_difference (smalll.begin (), smalll.end (),
62 odd.begin (), odd.end (), res_ins);
63
64 std::copy (result.begin (), result.end (), Iter (std::cout, " "));
65 std::cout << "}\n\n";
66
67 return 0;
68}
#define a1
Definition 17.names.cpp:225
volatile int result
std::ostream_iterator< int, char, std::char_traits< char > > Iter
Definition alg7.cpp:64
int main()