common: slot_vector: added `IsAllocated` to check if a slot already exists

This commit is contained in:
psucien 2024-06-18 15:02:01 +02:00
parent 723e3cd0f9
commit f375e0cfb0
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 IsAllocated(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();