Skip to content

Commit eee51d3

Browse files
author
Julian LALU
committed
Improve hashmap
1 parent 53f1684 commit eee51d3

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

interface/core/containers/hashset.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,12 @@ namespace hud
397397
{
398398
using mask::mask;
399399

400-
[[nodiscard]] constexpr bool has_free_slot() const noexcept
400+
[[nodiscard]] constexpr bool has_empty_slot() const noexcept
401401
{
402402
return *this;
403403
}
404404

405-
[[nodiscard]] constexpr u32 first_free_index() const noexcept
405+
[[nodiscard]] constexpr u32 first_empty_index() const noexcept
406406
{
407407
return first_non_null_index();
408408
}
@@ -413,12 +413,12 @@ namespace hud
413413
{
414414
using mask::mask;
415415

416-
[[nodiscard]] constexpr bool has_free_or_deleted_slot() const noexcept
416+
[[nodiscard]] constexpr bool has_empty_or_deleted_slot() const noexcept
417417
{
418418
return *this;
419419
}
420420

421-
[[nodiscard]] constexpr u32 first_free_or_deleted_index() const noexcept
421+
[[nodiscard]] constexpr u32 first_empty_or_deleted_index() const noexcept
422422
{
423423
return first_non_null_index();
424424
}
@@ -1002,7 +1002,7 @@ namespace hud
10021002
}
10031003

10041004
// If we have free slot, we don't find it
1005-
if (group.mask_of_empty_slot().has_free_slot())
1005+
if (group.mask_of_empty_slot().has_empty_slot())
10061006
{
10071007
return iterator {control_ptr_sentinel()};
10081008
}
@@ -1013,10 +1013,6 @@ namespace hud
10131013
}
10141014
}
10151015

1016-
constexpr void remove(const key_type &key) noexcept
1017-
{
1018-
}
1019-
10201016
[[nodiscard]]
10211017
constexpr const_iterator find(const key_type &key) const noexcept
10221018
{
@@ -1035,6 +1031,14 @@ namespace hud
10351031
return find(key) != end();
10361032
}
10371033

1034+
constexpr void remove(const key_type &key) noexcept
1035+
{
1036+
iterator it = find(key);
1037+
if (it != end())
1038+
{
1039+
}
1040+
}
1041+
10381042
/** Retrieves the allocator. */
10391043
[[nodiscard]] HD_FORCEINLINE constexpr const allocator_type &allocator() const noexcept
10401044
{
@@ -1396,7 +1400,7 @@ namespace hud
13961400

13971401
// Don't find the key
13981402
group_type::empty_mask empty_mask_of_group {group.mask_of_empty_slot()};
1399-
if (empty_mask_of_group.has_free_slot()) [[likely]]
1403+
if (empty_mask_of_group.has_empty_slot()) [[likely]]
14001404
{
14011405
return {insert_no_construct(h1, H2(hash)), true};
14021406
}
@@ -1518,9 +1522,9 @@ namespace hud
15181522
{
15191523
group_type group {control_ptr + slot_index};
15201524
group_type::empty_or_deleted_mask group_mask_that_match_h2 {group.mask_of_empty_or_deleted_slot()};
1521-
if (group_mask_that_match_h2.has_free_or_deleted_slot())
1525+
if (group_mask_that_match_h2.has_empty_or_deleted_slot())
15221526
{
1523-
u32 free_index {group_mask_that_match_h2.first_free_or_deleted_index()};
1527+
u32 free_index {group_mask_that_match_h2.first_empty_or_deleted_index()};
15241528
usize slot_index_that_is_free_or_deleted(slot_index + free_index & max_slot_count);
15251529
return slot_index_that_is_free_or_deleted;
15261530
}

0 commit comments

Comments
 (0)