// // #ifndef __SET_HPP__ #define __SET_HPP__ #include const int MAX_SET_SIZE = 10000; class set { private: bool s[MAX_SET_SIZE]; public: set(); set(int e); set(int e1, int e2); set(int e1, int e2, int e3); int size(); set operator+(const set& set2); // union set operator*(const set& set2); // intersection set operator-(const set& set2); // set difference bool operator[](int index) { if (index >= 0 && index < MAX_SET_SIZE) return s[index]; else return false; } bool operator==(const set& set2) const { for (int i = 0; i < MAX_SET_SIZE; i++) { if (s[i] != set2.s[i]) return false; } return true; } bool operator!=(const set& set2) const { return !(*this == set2); } // whether set1 is a subset of set2 bool operator<=(const set& set2) const { for (int i = 0; i < MAX_SET_SIZE; i++) { if (s[i] == true && set2.s[i] == false) return false; } return true; } bool operator>=(const set& set2) const { for (int i = 0; i < MAX_SET_SIZE; i++) { if (set2.s[i] == true && s[i] == false) return false; } return true; } bool operator<(const set& set2) const { return ((*this <= set2) && (*this != set2)); } bool operator>(const set& set2) const { return ((*this >= set2) && (*this != set2)); } friend std::ostream& operator<<(std::ostream& out, const set& set2); friend std::istream& operator>>(std::istream& in, set& set2); }; std::ostream& operator<<(std::ostream& out, const set& set2); std::istream& operator>>(std::istream& in, set& set2); #endif // !__SET_HPP__