#ifndef SET_PROJECTS_CATS__SET_H_
#define SET_PROJECTS_CATS__SET_H_
#include <vector>
class Set {
 public:
  explicit Set(const std::vector<int64_t>&);
  Set() = default;
  void Add(int64_t);
  void Remove(int64_t);
  std::vector <int64_t> Data() const;
  bool Contains(int64_t) const;
  Set Union(const Set&) const;
  Set Intersection(const Set&) const;
  Set Difference(const Set&) const;
  Set SymmetricDifference(const Set&) const;
 private:
  std::vector <int64_t> date_vector;
};

#endif

Set::Set(const std::vector<int64_t> & a) {
  if ( !a.size() ) {
    return;
  } else {
    this->date_vector.push_back(a[0]);
    for (auto i : a) {
      if (!this->Contains(i)) {
        this->date_vector.push_back(i);
      }
    }
  }
}

bool Set::Contains(int64_t a) const {
  for ( auto i : this->date_vector ) {
    if ( i == a ) {
      return true;
    }
  }
  return false;
}

void Set::Add(int64_t a) {
  if ( !this->Contains(a) ) {
    this->date_vector.push_back(a);
  }
}

void Set::Remove(int64_t a) {
  int cnt = 0;
  for ( auto i : this->date_vector ) {
    if ( a == i ) {
      this->date_vector.erase(this->date_vector.begin() + cnt);
      break;
    }
    cnt++;
  }
}

std::vector<int64_t> Set::Data() const {
  return this->date_vector;
}

Set Set::Union(const Set & a) const {
  std::vector <int64_t> new_vector = this->date_vector;
  for ( auto i : a.date_vector ) {
    if ( !this->Contains(i) ) {
      new_vector.push_back(i);
    }
  }
  return Set(new_vector);
}

Set Set::Intersection(const Set & a) const {
  std::vector <int64_t> new_vector;
  for ( auto i : a.date_vector ) {
    if ( this->Contains(i) ) {
      new_vector.push_back(i);
    }
  }
  return Set(new_vector);
}

Set Set::Difference(const Set & a) const {
  std::vector<int64_t> new_vector;
  for ( auto i : this->date_vector ) {
    if ( !a.Contains(i) ) {
      new_vector.push_back(i);
    }
  }
  return Set(new_vector);
}

Set Set::SymmetricDifference(const Set & a) const {
  std::vector <int64_t> new_vector;
  for ( auto i : a.date_vector ) {
    if ( !this->Contains(i) ) {
      new_vector.push_back(i);
    }
  }
  for ( auto i : this->date_vector ) {
    if ( !a.Contains(i) ) {
      new_vector.push_back(i);
    }
  }
  return Set(new_vector);
}