From 9fb7d90449ce798bbc014ac6d17261a9df5ee3f2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 5 Aug 2022 19:20:00 +1000 Subject: Change HashMap not to support multiple identical keys by default We do not seem to have any uses for this remaining, and this is better opt-in with MultiHashMap --- src/hash_map.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/hash_map.cc') diff --git a/src/hash_map.cc b/src/hash_map.cc index 4e45ab26..6972f34b 100644 --- a/src/hash_map.cc +++ b/src/hash_map.cc @@ -30,12 +30,23 @@ UnitTest test_hash_map{[] { kak_assert(map.size() == 2); } - // Multiple entries with the same key + // Replace Multiple entries with the same key { HashMap map; map.insert({10, 1}); map.insert({10, 2}); kak_assert(map.find_index(10) == 0); + kak_assert(map[10] == 2); + map.remove(10); + kak_assert(map.find_index(10) == -1); + } + + // Multiple entries with the same key + { + MultiHashMap map; + map.insert({10, 1}); + map.insert({10, 2}); + kak_assert(map.find_index(10) == 0); map.remove(10); kak_assert(map.find_index(10) == 0); map.remove(10); -- cgit v1.2.3