Maze Builder Docs 6.7.5
Loading...
Searching...
No Matches
lab.h
Go to the documentation of this file.
1#ifndef LAB_H
2#define LAB_H
3
4#include <memory>
5#include <optional>
6#include <tuple>
7#include <unordered_map>
8#include <utility>
9#include <vector>
10
12
14namespace mazes {
15
16class cell;
17class configurator;
18
20
24class lab {
25public:
26 explicit lab();
27
28 // Destructor
29 ~lab();
30
31 // Copy constructor
32 lab(const lab& other);
33
34 // Copy assignment operator
35 lab& operator=(const lab& other);
36
37 // Move constructor
38 lab(lab&& other) noexcept = default;
39
40 // Move assignment operator
41 lab& operator=(lab&& other) noexcept = default;
42
43 std::optional<std::tuple<int, int, int, int>> find(int p, int q) const noexcept;
44 std::optional<std::tuple<int, int, int, int>> find(int p, int q, int r) const noexcept;
45
46 void insert(int x, int y, int z, int w) noexcept;
47
48 bool empty() const noexcept;
49
50 int get_levels() const noexcept;
51 void set_levels(int levels) noexcept;
52
53 int get_random_block_id() const noexcept;
54
59 static void link(const std::shared_ptr<cell>& c1, const std::shared_ptr<cell>& c2, bool bidi = true) noexcept;
60
65 static void unlink(const std::shared_ptr<cell>& c1, const std::shared_ptr<cell>& c2, bool bidi = true) noexcept;
66
72 static void set_neighbors(configurator const& config, const std::vector<int>& indices, std::vector<std::shared_ptr<cell>>& cells_to_set) noexcept;
73private:
74
75 int calculate_cell_index(unsigned int row, unsigned int col, unsigned int level, unsigned int rows, unsigned int columns) const noexcept;
76
77
78 using pqmap = std::unordered_map<std::pair<int, int>, std::tuple<int, int, int, int>, pair_hash>;
79 pqmap m_p_q;
80
81 int levels;
82};
83}
84
85#endif // LAB_H
Cell class with links to other cells.
Definition cell.h:17
Configuration class for arguments.
Definition configurator.h:15
Holds mazes and provides search functions.
Definition lab.h:24
static void link(const std::shared_ptr< cell > &c1, const std::shared_ptr< cell > &c2, bool bidi=true) noexcept
Links two cell objects, optionally in both directions.
static void set_neighbors(configurator const &config, const std::vector< int > &indices, std::vector< std::shared_ptr< cell > > &cells_to_set) noexcept
Sets neighbors for a collection of cells based on the provided indices.
static void unlink(const std::shared_ptr< cell > &c1, const std::shared_ptr< cell > &c2, bool bidi=true) noexcept
Unlinks two cell objects, optionally in both directions.
Namespace for the maze builder.
Definition algo_interface.h:9
Hashing function to store a block's (x, z) position.
Definition hash_funcs.h:30