diff --git a/src/jc/cpp/hashtable.h b/src/jc/cpp/hashtable.h index 942c82c..ba39063 100644 --- a/src/jc/cpp/hashtable.h +++ b/src/jc/cpp/hashtable.h @@ -10,8 +10,7 @@ - Supports values with = operator VERSION: - 2.11 - (2024-12-28) - Added Full() - 2.10 - (2024-12-28) - Added SetCapacity() and dynamic size support + 2.10 - (2024-12-28) - Added SetCapacity(), Full() and Capacity() 2.01 - (2016-11-06) - Removed requirement of allocating memory at power of 2 sizes 2.00 - (2016-06-04) - Changed to two arrays: entries & values - Removed empty key (API change) @@ -301,6 +300,11 @@ class HashTable return m_Size; } + inline uint32_t Capacity() const + { + return m_Capacity; + } + inline bool Full() const { return m_Size == m_Capacity; diff --git a/test/hashtable.cpp b/test/hashtable.cpp index c494812..bc533ea 100644 --- a/test/hashtable.cpp +++ b/test/hashtable.cpp @@ -428,6 +428,7 @@ TEST_F(HashTableTest, SetCapacity) jc::HashTable ht; ht.SetCapacity(table_size); + ASSERT_EQ(table_size, ht.Capacity()); const uint32_t grow_iter_count = 20; for (uint32_t grow_iter = 1; grow_iter < grow_iter_count; ++grow_iter) @@ -435,6 +436,7 @@ TEST_F(HashTableTest, SetCapacity) uint32_t target_size = table_size + grow_iter; ht.SetCapacity(target_size); + ASSERT_EQ(target_size, ht.Capacity()); FillMaps(map, ht, target_size);