/* * set.cpp * * Created on: 14.01.2016 г. * Author: trifon */ #include "linked_list.cpp" #include "dictionary.h" template class D> class Set { private: using DT = D; DT dict; public: // проверка за празнота bool empty() const { return dict.keys().empty(); } // включване на елемент bool insert(T const& x) { return dict.add(x, false); } // изключване на елемент bool remove(T const& x) { return dict.remove(x); } // проверка за съдържане bool contains(T const& x) { return dict.lookup(x) != NULL; } // списък от елементи LinkedList elements() { return dict.keys(); } template using HashFunction = int (*)(K const&, int); void setHashFunction(HashFunction hf) { dict.setHashFunction(hf); } }; // Set // Set // template using HashSet = Set // HashSet // template using AVLSet = Set // AVLSet