common: slot_vector: added `is_allocated` to check if the slot already exists
This commit is contained in:
parent
d9036a702d
commit
d7a5cbfc95
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue