30 explicit grid(
unsigned int rows,
unsigned int columns,
unsigned int height = 1u);
34 explicit grid(std::tuple<unsigned int, unsigned int, unsigned int> dimensions);
58 template <
typename G = std::unique_ptr<gr
id_
interface>>
59 static std::optional<std::unique_ptr<grid>> make_opt(
const G g)
noexcept {
60 if (
const auto* gg =
dynamic_cast<const grid*
>(g.get())) {
61 return std::make_optional(std::make_unique<grid>(*gg));
70 virtual std::tuple<unsigned int, unsigned int, unsigned int>
get_dimensions() const noexcept override;
74 virtual
void to_vec(std::vector<std::shared_ptr<
cell>>& cells) const noexcept override;
78 virtual
void to_vec2(std::vector<std::vector<std::shared_ptr<
cell>>>& cells) const noexcept override;
83 virtual std::optional<std::
string>
contents_of(const std::shared_ptr<
cell>& c) const noexcept override;
99 virtual
void insert(std::shared_ptr<
cell> const& parent,
int index) noexcept;
106 virtual
bool update(std::shared_ptr<
cell>& parent,
int old_index,
int new_index) noexcept;
112 virtual std::shared_ptr<
cell>
search(std::shared_ptr<
cell> const& start,
int index) const noexcept;
117 virtual
void del(std::shared_ptr<
cell> parent,
int index) noexcept;
120 std::shared_ptr<
cell> m_binary_search_tree_root;
123 bool create_binary_search_tree(const std::vector<
int>& shuffled_indices);
124 void configure_cells(std::vector<std::shared_ptr<
cell>>& cells) noexcept;
127 void presort(std::shared_ptr<
cell> const& parent, std::vector<std::shared_ptr<
cell>>& cells) const noexcept;
130 void inorder(std::shared_ptr<
cell> const& parent, std::vector<std::shared_ptr<
cell>>& cells) const noexcept;
133 void sort_by_row_then_col(std::vector<std::shared_ptr<
cell>>& cells_to_sort) const noexcept;
135 std::function<
int(std::shared_ptr<
cell> const&, std::shared_ptr<
cell> const&)> m_sort_by_row_column;
137 std::function<
int(
unsigned int,
unsigned int)> m_calc_index;
139 std::tuple<
unsigned int,
unsigned int,
unsigned int> m_dimensions;
Binary tree algorithm for generating mazes.
Definition binary_tree.h:18
Cell class for maze generation.
Definition cell.h:14
Depth-first search algorithm for generating mazes.
Definition dfs.h:19
Interface for the grid class.
Definition grid_interface.h:26
General purpose grid class for maze generation.
Definition grid.h:18
grid(unsigned int rows, unsigned int columns, unsigned int height=1u)
Constructor for grid.
grid(const grid &other)
Copy constructor.
virtual std::tuple< unsigned int, unsigned int, unsigned int > get_dimensions() const noexcept override
Provides dimensions of grid in no assumed ordering.
virtual void to_vec(std::vector< std::shared_ptr< cell > > &cells) const noexcept override
Convert a 2D grid to a vector of cells (sorted by row then column)
virtual bool update(std::shared_ptr< cell > &parent, int old_index, int new_index) noexcept
virtual std::shared_ptr< cell > search(std::shared_ptr< cell > const &start, int index) const noexcept
grid & operator=(const grid &other)
Assignment operator.
grid & operator=(grid &&other) noexcept
Move assignment operator.
virtual void insert(std::shared_ptr< cell > const &parent, int index) noexcept
virtual std::optional< std::string > contents_of(const std::shared_ptr< cell > &c) const noexcept override
Get detailed information of a cell in the grid.
virtual std::optional< std::uint32_t > background_color_for(const std::shared_ptr< cell > &c) const noexcept override
Get the background color for a cell in the grid.
virtual void append(std::shared_ptr< grid_interface > const &other_grid) noexcept
virtual ~grid()
Destructor.
grid(grid &&other) noexcept
Move constructor.
virtual void del(std::shared_ptr< cell > parent, int index) noexcept
grid(std::tuple< unsigned int, unsigned int, unsigned int > dimensions)
Constructor for grid.
virtual void to_vec2(std::vector< std::vector< std::shared_ptr< cell > > > &cells) const noexcept override
Convert a 2D grid to a vector of vectors of cells (sorted by row then column)
Sidewinder algorithm for generating mazes.
Definition sidewinder.h:17
Namespace for the maze builder.
Definition algo_interface.h:9