I do such comparison of two std::set
#include
#include
using namespace std;
#include
#include
There are several set operations in C++ standard library header
.
std::set_difference gives those elements that are in set 1 but not set 2.
std::set_intersection gives those elements that are in both sets.
std::set_symmetric_difference gives those elements that appear in one of the sets but not both.
std::set_union gives those elements that are in either set 1 or set 2.
The algorithms above can also be applied to STL containers other than std::set
, but the containers have to be sorted first (std::set
is sorted by default).