#pragma once
#include <vector>
class Set {
public:
std::vector<int64_t> array;
explicit Set(const std::vector<int64_t> &vec) {
this->array = vec;
}
Set() {}
std::vector<int64_t> Data(){
return this->array;
}
void Add(int64_t number) {
bool present = false;
for (int64_t i : array) {
if (i == number) {
present = true;
break;
}
}
if (!present) {
this->array.push_back(number);
}
}
void Remove(int64_t number) {
for (unsigned int i = 0; i < this->array.size(); i++) {
if (this->array[i] == number) {
this->array.erase(this->array.begin() + i);
break;
}
}
}
bool Contains(int64_t number) const {
for (int64_t i : this->array) {
if (i == number) {
return true;
}
}
return false;
}
Set Union(const Set& other) {
for (int64_t i : other.array) {
this->Add(i);
}
return *this;
}
Set Intersection(const Set& other) const {
Set *intersection = new Set();
for (int64_t i : this->array) {
if (other.Contains(i)) {
intersection->Add(i);
}
}
return *intersection;
}
Set Difference(const Set& other) const {
Set *difference = new Set();
for (int64_t i : this->array) {
if (!other.Contains(i)) {
difference->Add(i);
}
}
return *difference;
}
Set SymmetricDifference(const Set& other) const {
Set *simdiff = new Set();
for (int64_t i : this->array) {
if (!other.Contains(i)) {
simdiff->Add(i);
}
}
for (int64_t i : other.array) {
if (!this->Contains(i)) {
simdiff->Add(i);
}
}
return *simdiff;
}
};