Created
October 26, 2011 06:15
-
-
Save hidsh/10f41440929dbf5b8b93 to your computer and use it in GitHub Desktop.
test for set and merge using STL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set<int> i1, i2, i3; | |
int max = 10000; | |
for(int i=1; i<max; i++) { | |
i1.insert(i*5); | |
i2.insert(i*10); | |
} | |
// set_union | |
cout << "set_union --------" << endl; | |
std::set_union(i1.begin(), i1.end(), | |
i2.begin(), i2.end(), | |
insert_iterator<set<int> >(i3, i3.begin() )); | |
// caution: the following is not permitted because to try to write to readonly field. | |
// std::set_union(i1.begin(), i1.end(), i2.begin(), i2.end(), i3.begin() ); | |
// ^^^^^^^^^^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment