Maze Builder Docs 8.8.13
Loading...
Searching...
No Matches
mask.h
Go to the documentation of this file.
1#ifndef MASK_H
2#define MASK_H
3
4#include <string>
5#include <string_view>
6#include <utility>
7#include <vector>
8
11namespace mazes
12{
13 class randomizer;
14
19 class mask
20 {
21 public:
25 explicit mask(unsigned int rows, unsigned int columns);
26
27 ~mask() = default;
28
29 mask(const mask &) = default;
30 mask &operator=(const mask &) = default;
31
32 mask(mask &&) noexcept = default;
33 mask &operator=(mask &&) noexcept = default;
34
39 bool operator()(unsigned int row, unsigned int column) const noexcept;
40
45 void set(unsigned int row, unsigned int column, bool is_on) noexcept;
46
49 int count() const noexcept;
50
55 std::pair<unsigned int, unsigned int> random_location(randomizer &rng) const noexcept;
56
59 [[nodiscard]] unsigned int rows() const noexcept;
60
63 [[nodiscard]] unsigned int columns() const noexcept;
64
70 static mask from_txt(const std::string &filename);
71
77 static mask from_string(std::string_view text);
78
83 static mask from_source(std::string_view source);
84
85 private:
86 std::vector<std::vector<bool>> m_bits;
87 };
88} // namespace mazes
89
90#endif // MASK_H
void set(unsigned int row, unsigned int column, bool is_on) noexcept
Set a cell's availability.
static mask from_string(std::string_view text)
Load a mask from an inline string.
static mask from_txt(const std::string &filename)
Load a mask from a text file.
std::pair< unsigned int, unsigned int > random_location(randomizer &rng) const noexcept
Get a random available cell location.
unsigned int columns() const noexcept
Get the number of columns.
int count() const noexcept
Count the number of available cells.
unsigned int rows() const noexcept
Get the number of rows.
mask(unsigned int rows, unsigned int columns)
Construct a mask with specified dimensions, all cells enabled.
static mask from_source(std::string_view source)
Load a mask from either a file path or an inline string.
Provides random-number generating capabilities.
Definition randomizer.h:16