#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class Set { private: std::vector set; public: Set() = default; explicit Set(const std::vector& v) { for (int64_t i = 0; i < v.size(); i++) { this->Add(v[i]); } } std::vector Data() const { return this->set; } void Add(int64_t num) { if (!this->Contains(num)) { this->set.push_back(num); } } void Remove(int64_t num) { this->set.erase(find(this->set.begin(), this->set.end(), num)); } bool Contains(int64_t num) const { return find(this->set.begin(), this->set.end(), num) != this->set.end(); } Set Union(const Set& other) const { Set s; for (int64_t i = 0; i < this->set.size(); i++) { s.Add(this->Data()[i]); } for (int64_t j = 0; j < other.set.size(); j++) { s.Add(other.Data()[j]); } return s; } Set Intersection(const Set& other) const { Set s; for (int64_t i = 0; i < other.set.size(); i++) { if (this->Contains(other.set[i])) { s.Add(other.Data()[i]); } } return s; } Set Difference(const Set& other) const { Set s; for (int64_t i = 0; i < this->set.size(); i++) { if (!other.Contains(this->Data()[i])) { s.Add(this->Data()[i]); } } return s; } Set SymmetricDifference(const Set& other) const { Set s; s = this->Difference(other); s = s.Union(other.Difference(this->set)); return s; } };