I want to write a C ++ class that offers set operations that work with row vectors and vectors of my own data type. Are there any simple ways to do this, and not write different functions for each data type? So far I have written operations for row vectors. The following is an example of my join join:
vector<string> SetOperations::set_union(vector<string> set1,
vector<string> set2) {
for(std::vector<int>::size_type i = 0; i < set1.size(); i++) {
set1.push_back(set2.at(i));
}
return set1;
}
So, I want to repeat the same thing, but where stringthey say my_data_type, which is the structure of the various members. Let's say it looks like this:
struct my_data_type {
int label;
vector<string> x;
vector<string> y;
string str;
};
The function for each data type will also not be as simple as my function set_union(...), because, of course, will I need to check the equality for each member my_data_typein the case of a set of intersections?
, ++, .
.