common: slot_vector: added `is_allocated` to check if the slot already exists

This commit is contained in:
psucien 2024-06-22 19:04:42 +02:00
parent d9036a702d
commit d7a5cbfc95
1 changed files with 7 additions and 0 deletions

View File

@ -54,6 +54,13 @@ public:
return values[id.index].object; return values[id.index].object;
} }
bool is_allocated(SlotId id) const {
if (id && id.index / 64 < stored_bitset.size()) {
return ((stored_bitset[id.index / 64] >> (id.index % 64)) & 1) != 0;
}
return false;
}
template <typename... Args> template <typename... Args>
[[nodiscard]] SlotId insert(Args&&... args) noexcept { [[nodiscard]] SlotId insert(Args&&... args) noexcept {
const u32 index = FreeValueIndex(); const u32 index = FreeValueIndex();