Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
set_intr.cpp
Go to the documentation of this file.
1
29#include <algorithm>
30#include <set>
31#include <iostream>
32#include <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 std::set<int, std::less<int>, std::allocator<int> >
40 odd (a1 + 0, a1 + 6),
41 result,
42 smalll (a3 + 0, a3 + 4);
43
44 // Create an insert_iterator for result.
45
46 std::insert_iterator<std::set<int, std::less<int>, std::allocator<int> > >
47 res_ins (result, result.begin ());
48
49 // Demonstrate set_intersection.
50
51 typedef std::ostream_iterator<int, char, std::char_traits<char> > Iter;
52
53 std::cout << "The result of:\n{";
54
55 std::copy (smalll.begin (),smalll.end (), Iter (std::cout, " "));
56 std::cout << "} intersection {";
57
58 std::copy (odd.begin (), odd.end (), Iter (std::cout, " "));
59 std::cout << "} =\n{";
60
61 std::set_intersection (smalll.begin (),smalll.end (),
62 odd.begin (), odd.end(),
63 res_ins);
64
65 std::copy (result.begin (), result.end (), Iter (std::cout, " "));
66 std::cout << "}\n\n";
67
68 return 0;
69}
#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()
Definition set_intr.cpp:34