Skip to content

Commit a506f85

Browse files
committed
update HashTable
1 parent 927f7f6 commit a506f85

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

data-structures/HashTable/include/HashTable.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include <cstddef>
77
#include <stdexcept>
88

9-
const size_t DefautBucketsCounts = 11;
9+
static const size_t _num_primes = 8;
10+
static const unsigned _prime_list[_num_primes] = {11, 13, 17, 19, 23, 29, 31, 37};
1011

1112
template <typename Key, typename Value>
1213
class HashTable{
@@ -28,8 +29,11 @@ class HashTable{
2829
void clear();
2930
// Buckets
3031
size_t buckets_count() const;
32+
size_t max_buckets_count() const;
3133
size_t bucket_size(const size_t n) const;
3234
size_t bucket(const Key& key) const;
35+
private:
36+
unsigned _next_prime(unsigned n);
3337
private:
3438
struct _KVNode{
3539
Key _key;

0 commit comments

Comments
 (0)