/* Lecture Code 4.1
 *
 * Set algorithms, including a demo of some of the STL iterator adapters.
 *
 */
 
 #include <iostream>
 #include <algorithm>
 #include <set>
 using namespace std;
 
 int main()
 {
	 set<int> evens, odds;
	 for(int i = 0; i < 10; i++)
	 {
		 evens.insert(i * 2);
		 odds.insert(i * 2 + 1);
	 }
	 
	 set<int> result;
	 set_union(evens.begin(), evens.end(), odds.begin(), odds.end(),
			inserter(result, result.begin()));
	 
	 /* Using the "copy" algorithm, print out the contents of the resulting set. */
	 copy(result.begin(), result.end(), ostream_iterator<int>(cout, " "));
	 
	 cout << endl;
	 
	 return 0;
 }