common: slot_vector: added `is_allocated` to check if the slot already exists
This commit is contained in:
parent
8475a62a46
commit
acc4ef7b4c
|
@ -54,6 +54,10 @@ public:
|
||||||
return values[id.index].object;
|
return values[id.index].object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_allocated(SlotId id) const {
|
||||||
|
return ReadStorageBit(id.index);
|
||||||
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
@ -107,7 +111,7 @@ private:
|
||||||
stored_bitset[index / 64] &= ~(u64(1) << (index % 64));
|
stored_bitset[index / 64] &= ~(u64(1) << (index % 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadStorageBit(u32 index) noexcept {
|
bool ReadStorageBit(u32 index) const noexcept {
|
||||||
return ((stored_bitset[index / 64] >> (index % 64)) & 1) != 0;
|
return ((stored_bitset[index / 64] >> (index % 64)) & 1) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue