#include #include #include #ifndef SET_SET_H #define SET_SET_H class Set { public: std::set objSet; explicit Set(const std::vector &vect) { for (int64_t i : vect) { this->objSet.insert(i); } } Set() = default; void Add(int64_t num) { this->objSet.insert(num); } void Remove(int64_t num) { this->objSet.erase(num); } bool Contains(int64_t num) const { if (this->objSet.find(num) == this->objSet.end()) { return false; } else { return true; } } Set Union(const Set &s) const { Set resObj; for (int64_t el : this->objSet) { resObj.Add(el); } for (int64_t el : s.objSet) { resObj.Add(el); } return resObj; } Set Intersection(const Set &s) const { Set resObj; for (int64_t el : this->objSet) { if (s.Contains(el)) { resObj.Add(el); } } return resObj; } Set Difference(const Set &s) const { Set resObj; for (int64_t el : this->objSet) { if (!s.Contains(el)) { resObj.Add(el); } } return resObj; } Set SymmetricDifference(const Set &s) const { Set resObj; for (int64_t el : this->objSet) { if (!s.Contains(el)) { resObj.Add(el); } } for (int64_t el : s.objSet) { if (!this->Contains(el)) { resObj.Add(el); } } return resObj; } std::vector Data() const { std::vector res; for (int64_t el : this->objSet) { res.push_back(el); } return res; } }; #endif // SET_SET_H