Maze Builder Docs 6.0.1
Loading...
Searching...
No Matches
cell.h
Go to the documentation of this file.
1#ifndef CELL_H
2#define CELL_H
3
4#include <memory>
5#include <vector>
6#include <unordered_map>
7#include <cstdint>
8
9namespace mazes {
10
14class cell {
15
16public:
19 explicit cell(std::int32_t index = 0);
20
25 void link(std::shared_ptr<cell> c1, std::shared_ptr<cell> c2, bool bidi=true);
26
31 void unlink(std::shared_ptr<cell> c1, std::shared_ptr<cell> c2, bool bidi=true);
32
36 const std::unordered_map<std::shared_ptr<cell>, bool>& get_links();
37
41 bool is_linked(const std::shared_ptr<cell>& c);
42
45 bool has_northern_neighbor() const noexcept;
46
49 bool has_southern_neighbor() const noexcept;
50
53 bool has_eastern_neighbor() const noexcept;
54
57 bool has_western_neighbor() const noexcept;
58
61 std::vector<std::shared_ptr<cell>> get_neighbors() const noexcept;
62
65 int32_t get_index() const noexcept;
66
69 void set_index(std::int32_t next_index) noexcept;
70
73 std::shared_ptr<cell> get_north() const;
74
77 std::shared_ptr<cell> get_south() const;
78
81 std::shared_ptr<cell> get_east() const;
82
85 std::shared_ptr<cell> get_west() const;
86
89 void set_north(std::shared_ptr<cell> const& other);
90
93 void set_south(std::shared_ptr<cell> const& other);
94
97 void set_east(std::shared_ptr<cell> const& other);
98
101 void set_west(std::shared_ptr<cell> const& other);
102private:
103 bool has_key(const std::shared_ptr<cell>& c);
104
105 std::unordered_map<std::shared_ptr<cell>, bool> m_links;
106
107 std::int32_t m_index;
108
109 std::shared_ptr<cell> m_north;
110 std::shared_ptr<cell> m_south;
111 std::shared_ptr<cell> m_east;
112 std::shared_ptr<cell> m_west;
113}; // class
114
115} // namespace
116
117#endif // CELL_H
Cell class for maze generation.
Definition cell.h:14
const std::unordered_map< std::shared_ptr< cell >, bool > & get_links()
Retrieves a constant reference to an unordered map of cell links and their boolean states.
std::shared_ptr< cell > get_south() const
Retrieves a shared pointer to the cell located to the south.
bool has_western_neighbor() const noexcept
Checks if there is a western neighbor.
std::shared_ptr< cell > get_north() const
Retrieves a shared pointer to the cell located to the north.
void link(std::shared_ptr< cell > c1, std::shared_ptr< cell > c2, bool bidi=true)
Links two cell objects, optionally in both directions.
bool has_southern_neighbor() const noexcept
Checks if the current object has a southern neighbor.
void unlink(std::shared_ptr< cell > c1, std::shared_ptr< cell > c2, bool bidi=true)
Unlinks two cells, optionally in both directions.
bool has_eastern_neighbor() const noexcept
Checks if there is an eastern neighbor.
cell(std::int32_t index=0)
Constructs a cell object with an optional index.
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.
bool has_northern_neighbor() const noexcept
Checks if the current object has a northern neighbor.
std::shared_ptr< cell > get_west() const
Retrieves a shared pointer to the cell located to the west.
void set_south(std::shared_ptr< cell > const &other)
Sets the southern neighbor of the current cell.
void set_east(std::shared_ptr< cell > const &other)
Sets the east neighbor of the current cell.
bool is_linked(const std::shared_ptr< cell > &c)
Checks if a cell is linked.
std::shared_ptr< cell > get_east() const
Retrieves a shared pointer to the cell located to the east.
void set_north(std::shared_ptr< cell > const &other)
Sets the northern neighbor of the current cell.
std::vector< std::shared_ptr< cell > > get_neighbors() const noexcept
Retrieves a list of neighboring cells.
void set_west(std::shared_ptr< cell > const &other)
Sets the west neighbor of the current cell.
Namespace for the maze builder.
Definition algo_interface.h:9