8#include <unordered_map>
22 cell_pool() =
default;
23 cell_pool(
const cell_pool &) =
delete;
24 cell_pool &operator=(
const cell_pool &) =
delete;
29 void acquire(std::uint8_t rows, std::uint8_t cols, std::uint8_t levels);
35 [[nodiscard]] std::span<const std::shared_ptr<
cell>>
view() const noexcept;
38 [[nodiscard]] std::shared_ptr<
cell>
at(
int index) const noexcept;
43 [[nodiscard]] std::
size_t size() const noexcept {
return m_active; }
45 [[nodiscard]] std::size_t capacity() const noexcept {
return m_cells.size(); }
48 std::vector<std::shared_ptr<cell>> m_cells;
49 std::unordered_map<const cell *, int> m_indices;
50 std::size_t m_active{0};
std::span< const std::shared_ptr< cell > > view() const noexcept
Active cells in index order (level-major, then row, then column).
void release() noexcept
Unlink all active cells and deactivate them, keeping the allocated cells for reuse.
int index_of(const cell *c) const noexcept
Linear index of an active cell, or -1.
void acquire(std::uint8_t rows, std::uint8_t cols, std::uint8_t levels)
Prepare rows * cols * levels cells, allocating only what the pool is missing. Every active cell is un...
std::shared_ptr< cell > at(int index) const noexcept
Active cell at a linear index, or nullptr.
Cell class with links to other cells.
Definition cell.h:18