Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/jc/cpp/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +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.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
Expand Down Expand Up @@ -300,6 +301,11 @@ class HashTable
return m_Size;
}

inline bool Full() const
{
return m_Size == m_Capacity;
}

class Iterator
{
const HashTable<KEY, VALUE>* m_HashTable;
Expand Down
3 changes: 2 additions & 1 deletion test/hashtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,13 @@ TEST_F(HashTableTest, SetCapacity)
{
uint32_t target_size = table_size + grow_iter;

ht.SetCapacity(target_size + grow_iter);
ht.SetCapacity(target_size);

FillMaps(map, ht, target_size);

ASSERT_EQ(map.size(), ht.Size());
ASSERT_EQ(target_size, ht.Size());
ASSERT_TRUE(ht.Full());

// Compare
AssertEqual(map, ht);
Expand Down
Loading