72 using Element256 = std::array<Element, 256>;
75 template<
typename... Args>
78 if (free !=
Index(-1)) {
83 pool.push_back(std::make_unique<Element256>());
85 idx =
Index(((pool.size() - 1) << 8) + cntr);
89 new(ptr) T(std::forward<Args>(args)...);
97 auto& elem = get(idx);
108 for (
auto i :
xrange(pool.size())) {
109 const auto& elem256 = *pool[i];
110 const T*
begin = &elem256[0].t;
112 if ((
begin <= ptr) && (ptr <
end)) {
121 return narrow<Index>(256 * pool.size());
125 [[nodiscard]]
const Element& get(
Index idx)
const {
return (*pool[idx >> 8])[idx & 255]; }
126 [[nodiscard]] Element& get(
Index idx) {
return (*pool[idx >> 8])[idx & 255]; }
129 std::vector<std::unique_ptr<Element256>> pool;
void remove(const T *ptr)
Index ptr2Index(const T *ptr) const
T & operator[](Index idx)
const T & operator[](Index idx) const
EmplaceResult emplace(Args &&...args)
uint32_t next(octet_iterator &it, octet_iterator end)
constexpr auto xrange(T e)
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)