Maze Builder Docs 6.0.1
All Classes Namespaces Files Functions Enumerations Friends Pages
mazes::grid Class Reference

General purpose grid class for maze generation. More...

#include <grid.h>

Inheritance diagram for mazes::grid:
[legend]
Collaboration diagram for mazes::grid:
[legend]

Public Member Functions

 grid (unsigned int rows=1u, unsigned int columns=1u, unsigned int height=1u)
 Constructor for grid.
 
 grid (std::tuple< unsigned int, unsigned int, unsigned int > dimensions)
 Constructor for grid.
 
 grid (const grid &other)
 Copy constructor.
 
gridoperator= (const grid &other)
 Assignment operator.
 
 grid (grid &&other) noexcept
 Move constructor.
 
gridoperator= (grid &&other) noexcept
 Move assignment operator.
 
virtual ~grid ()
 Destructor.
 
virtual std::future< bool > get_future () noexcept
 Initialize and configure.
 
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 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)
 
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.
 
std::shared_ptr< cellsearch (int index) const noexcept
 
int count () const noexcept
 Get the count of cells in the grid.
 
- Public Member Functions inherited from mazes::grid_interface

Protected Member Functions

void build_fut (std::vector< int > const &indices) noexcept
 Builds a future based on the provided indices.
 
void configure_cells (std::vector< std::shared_ptr< cell > > &cells) const noexcept
 Configure cells by neighbors (N, S, E, W)
 

Protected Attributes

std::promise< bool > m_config_promise
 
std::mutex m_cells_mutex
 
std::unordered_map< int, std::shared_ptr< cell > > m_cells
 

Friends

class binary_tree
 Friend classes.
 
class dfs
 
class sidewinder
 

Detailed Description

General purpose grid class for maze generation.

Constructor & Destructor Documentation

◆ grid() [1/4]

mazes::grid::grid ( unsigned int rows = 1u,
unsigned int columns = 1u,
unsigned int height = 1u )
explicit

Constructor for grid.

Parameters
rows
columns
height

◆ grid() [2/4]

mazes::grid::grid ( std::tuple< unsigned int, unsigned int, unsigned int > dimensions)
explicit

Constructor for grid.

Parameters
dimensions

◆ grid() [3/4]

mazes::grid::grid ( const grid & other)

Copy constructor.

Parameters
other

◆ grid() [4/4]

mazes::grid::grid ( grid && other)
noexcept

Move constructor.

Parameters
other

Member Function Documentation

◆ background_color_for()

virtual std::optional< std::uint32_t > mazes::grid::background_color_for ( const std::shared_ptr< cell > & c) const
overridevirtualnoexcept

Get the background color for a cell in the grid.

Parameters
c
Returns

Implements mazes::grid_interface.

Reimplemented in mazes::colored_grid, and mazes::distance_grid.

◆ build_fut()

void mazes::grid::build_fut ( std::vector< int > const & indices)
protectednoexcept

Builds a future based on the provided indices.

Parameters
indicesA constant reference to a vector of integers representing the indices.

◆ configure_cells()

void mazes::grid::configure_cells ( std::vector< std::shared_ptr< cell > > & cells) const
protectednoexcept

Configure cells by neighbors (N, S, E, W)

Parameters
cells

◆ contents_of()

virtual std::optional< std::string > mazes::grid::contents_of ( const std::shared_ptr< cell > & c) const
overridevirtualnoexcept

Get detailed information of a cell in the grid.

Parameters
c
Returns

Implements mazes::grid_interface.

Reimplemented in mazes::colored_grid, and mazes::distance_grid.

◆ count()

int mazes::grid::count ( ) const
noexcept

Get the count of cells in the grid.

Returns
The number of cells in the grid

◆ get_dimensions()

virtual std::tuple< unsigned int, unsigned int, unsigned int > mazes::grid::get_dimensions ( ) const
overridevirtualnoexcept

Provides dimensions of grid in no assumed ordering.

Returns

Implements mazes::grid_interface.

◆ get_future()

virtual std::future< bool > mazes::grid::get_future ( )
virtualnoexcept

Initialize and configure.

Parameters
callbacknotifies when configuration is complete
Returns

Reimplemented in mazes::distance_grid.

◆ operator=() [1/2]

grid & mazes::grid::operator= ( const grid & other)

Assignment operator.

Parameters
other
Returns

◆ operator=() [2/2]

grid & mazes::grid::operator= ( grid && other)
noexcept

Move assignment operator.

Parameters
other
Returns

◆ search()

std::shared_ptr< cell > mazes::grid::search ( int index) const
noexcept
Parameters
index
Returns

◆ to_vec()

virtual void mazes::grid::to_vec ( std::vector< std::shared_ptr< cell > > & cells) const
overridevirtualnoexcept

Convert a 2D grid to a vector of cells (sorted by row then column)

Parameters
cells

Implements mazes::grid_interface.

◆ to_vec2()

virtual void mazes::grid::to_vec2 ( std::vector< std::vector< std::shared_ptr< cell > > > & cells) const
overridevirtualnoexcept

Convert a 2D grid to a vector of vectors of cells (sorted by row then column)

Parameters
cells

Implements mazes::grid_interface.


The documentation for this class was generated from the following file: