From 88492598475b3f434d144f24087ef9a5c81d34ea Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Tue, 3 Dec 2019 22:26:47 +0100
Subject: [PATCH] Cuckoo hash: The number of buckets should stay constant
---
09-cuckoo_hash/cpp/cuckoo_hash.h | 1 +
09-cuckoo_hash/python/cuckoo_hash.py | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/09-cuckoo_hash/cpp/cuckoo_hash.h b/09-cuckoo_hash/cpp/cuckoo_hash.h
index 6323dff..6884dcf 100644
--- a/09-cuckoo_hash/cpp/cuckoo_hash.h
+++ b/09-cuckoo_hash/cpp/cuckoo_hash.h
@@ -66,6 +66,7 @@ public:
CuckooTable(unsigned num_buckets)
{
// Initialize the table with the given number of buckets.
+ // The number of buckets is expected to stay constant.
this->num_buckets = num_buckets;
table.resize(num_buckets, UNUSED);
diff --git a/09-cuckoo_hash/python/cuckoo_hash.py b/09-cuckoo_hash/python/cuckoo_hash.py
index 8c2560d..72a415c 100644
--- a/09-cuckoo_hash/python/cuckoo_hash.py
+++ b/09-cuckoo_hash/python/cuckoo_hash.py
@@ -31,7 +31,8 @@ class CuckooTable:
"""
def __init__(self, num_buckets):
- """Initialize the table with the given number of buckets."""
+ """Initialize the table with the given number of buckets.
+ The number of buckets is expected to stay constant."""
# The array of buckets
self.num_buckets = num_buckets
--
GitLab