7#include <unordered_map>
21 explicit cell(std::int32_t index = 0);
46 void add_link(
const std::shared_ptr<cell>& other);
54 std::vector<std::pair<std::shared_ptr<cell>,
bool>>
get_links()
const;
75 struct weak_ptr_equal {
78 bool operator()(
const std::weak_ptr<T>& lhs,
const std::weak_ptr<T>& rhs)
const {
80 return !lhs.owner_before(rhs) && !rhs.owner_before(lhs);
84 bool has_key(
const std::shared_ptr<cell>& c);
86 std::unordered_map<std::weak_ptr<cell>, bool,
weak_ptr_hash, weak_ptr_equal> m_links;
88 mutable std::shared_mutex m_links_mutex;
Cell class with links to other cells.
Definition cell.h:17
void add_link(const std::shared_ptr< cell > &other)
Add a link to another cell (passage between cells)
cell & operator=(const cell &other)
Assigns the value of another cell to this cell.
cell(const cell &other)
Copy constructor for the cell class.
~cell()
Destroys the cell object and releases any associated resources.
cell(std::int32_t index=0)
Constructs a cell object with an optional index.
cell(cell &&other) noexcept
Move constructor for the cell class. Transfers the resources from another cell to this one.
void set_index(std::int32_t next_index) noexcept
Sets the index to the specified value.
int32_t get_index() const noexcept
Retrieves the index of the current cell.
void cleanup_links()
Cleans up or removes links, typically as part of a resource management or shutdown process.
void remove_link(const std::shared_ptr< cell > &other)
Remove a link to another cell.
std::vector< std::pair< std::shared_ptr< cell >, bool > > get_links() const
Retrieves links to other cells.
cell & operator=(cell &&other) noexcept
Move assignment operator for the cell class.
bool is_linked(const std::shared_ptr< cell > &c)
Checks if a cell is linked.
Namespace for the maze builder.
Definition algo_interface.h:9
Hashing function to store a weak_ptr.
Definition hash_funcs.h:65