Skip to content

Instantly share code, notes, and snippets.

@shafreeck
Created December 17, 2010 14:57
Show Gist options
  • Save shafreeck/745060 to your computer and use it in GitHub Desktop.
Save shafreeck/745060 to your computer and use it in GitHub Desktop.
code example to min
set<int>::iterator it1 = s1.begin();
set<int>::iterator it2 = s2.begin();
while(it1 != s1.end() && it2 != s2.end())
{
if(*it1 < *it2)
{
result.push_back(*it1);
++it1;
}
else if(*it1 == *it2)
{
++it1;
++it2;
}
else
{
result.push_back(*it2);
++it2;
}
}
if(it1 != s1.end())
result.insert(result.end(),it1,s1.end());
else if(it2 != s2.end())
result.insert(result.end(),it2,s2.end());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment