#ifndef HSET_H_INCLUDED #define HSET_H_INCLUDED #include #include #include #include #include "hasher.h" #include "hset_iter.h" template class hset { private: static constexpr unsigned table_size=5; std::vector> table; public: using iterator = hset_iter; using value_type = T; using size_type = size_t; hset() : table(table_size) { } hset(const hset &) = default; hset& operator=(const hset &) = default; ~hset() = default; void insert(const T &datum) { auto hashval = H()(datum) % table.size(); auto &lr = table[hashval]; if (find(lr.begin(), lr.end(), datum) == lr.end()) lr.push_back(datum); } // Walk down the hash table, adding up all the sizes. size_type size() const { size_type total = 0; for (const auto &row : table) total += row.size(); return total; } iterator begin() const { return iterator(&table, 0); } iterator end() const { return iterator(&table, size()); } void dump() const { for (size_t i=0; i