Skip to content

Commit e75e1f1

Browse files
author
Julian LALU
committed
Improve hashmap
1 parent f32fa58 commit e75e1f1

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

interface/core/containers/hashset.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,10 @@ namespace hud
10131013
}
10141014
}
10151015

1016+
constexpr void remove(const key_type &key) noexcept
1017+
{
1018+
}
1019+
10161020
[[nodiscard]]
10171021
constexpr const_iterator find(const key_type &key) const noexcept
10181022
{

test/hashmap/hashmap_misc.cpp

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,53 @@ GTEST_TEST(hashmap, metadata)
8282
}
8383
hud_assert_eq(indices[0], 0);
8484
hud_assert_eq(indices[1], 4);
85-
}
85+
}
86+
87+
GTEST_TEST(array, count_return_count_of_element)
88+
{
89+
// using type = usize;
90+
// using HashMapType = hud::hashmap<type, type>;
91+
92+
// const auto test = []()
93+
// {
94+
// HashMapType map;
95+
96+
// // Count return 0 if array is empty
97+
// bool empty_ok = map.count() == 0;
98+
99+
// // Count return number of element if not empty
100+
// constexpr usize COUNT = 256;
101+
// for (usize value = 0; value < COUNT; value++)
102+
// {
103+
// map.add(value, value);
104+
// }
105+
// bool return_correct_count = map.count() == COUNT;
106+
107+
// // Count return number of element after remove
108+
// // Remove half
109+
// for (usize value = 0; value < COUNT; value += 2)
110+
// {
111+
// map.erase(value);
112+
// }
113+
// bool return_correct_count_after_erase_some = map.count() == COUNT;
114+
// return std::tuple {empty_ok, return_correct_count, return_correct_count_after_erase_some};
115+
// };
116+
117+
// // Non constant
118+
// {
119+
// HashMapType map;
120+
// const auto result = test();
121+
// hud_assert_eq(std::get<0>(result));
122+
// hud_assert_eq(std::get<1>(result));
123+
// hud_assert_eq(std::get<2>(result));
124+
// }
125+
126+
// // Constant
127+
// {
128+
// HashMapType map;
129+
// constexpr auto result = test();
130+
// hud_assert_eq(std::get<0>(result));
131+
// hud_assert_eq(std::get<1>(result));
132+
// hud_assert_eq(std::get<2>(result));
133+
// }
134+
}

0 commit comments

Comments
 (0)