Distances utility class for counting paths and nodes.
More...
#include <distances.h>
|
| distances (std::shared_ptr< cell > root) |
| Constructor that initializes the distances object with a given root cell.
|
|
int & | operator[] (const std::shared_ptr< cell > &cell) noexcept |
| Overloaded operator to access the distance of a cell.
|
|
const int & | operator[] (const std::shared_ptr< cell > &cell) const noexcept |
| Accesses the value associated with a given cell in a shared pointer.
|
|
void | set (std::shared_ptr< cell > cell, int distance) noexcept |
| Sets the distance of a cell in the distances object.
|
|
bool | contains (const std::shared_ptr< cell > &cell) const noexcept |
| Checks if a given cell is contained in the distances object.
|
|
std::shared_ptr< distances > | path_to (std::shared_ptr< cell > goal) const noexcept |
| Computes the shortest path to a goal cell within a distances object.
|
|
std::pair< std::shared_ptr< cell >, int > | max () const noexcept |
| Computes the maximum distance and cell in a distances object.
|
|
void | collect_keys (std::vector< std::shared_ptr< cell > > &cells) const noexcept |
| Collects keys from a vector of shared pointers to cell objects.
|
|
std::shared_ptr< distances > | dist () const noexcept |
| Returns a shared pointer to a distances object.
|
|
Distances utility class for counting paths and nodes.
This class is used to compute the distances between cells in a maze
◆ distances()
mazes::distances::distances |
( |
std::shared_ptr< cell > | root | ) |
|
|
explicit |
Constructor that initializes the distances object with a given root cell.
- Parameters
-
root | A shared pointer to the root cell used to initialize the distances object. |
◆ collect_keys()
void mazes::distances::collect_keys |
( |
std::vector< std::shared_ptr< cell > > & | cells | ) |
const |
|
noexcept |
Collects keys from a vector of shared pointers to cell objects.
- Parameters
-
cells | A reference to a vector of shared pointers to cell objects from which keys will be collected. |
◆ contains()
bool mazes::distances::contains |
( |
const std::shared_ptr< cell > & | cell | ) |
const |
|
noexcept |
Checks if a given cell is contained in the distances object.
- Parameters
-
cell | A shared pointer to the cell to check for containment. |
◆ dist()
std::shared_ptr< distances > mazes::distances::dist |
( |
| ) |
const |
|
noexcept |
Returns a shared pointer to a distances object.
- Returns
- A std::shared_ptr pointing to a distances object.
◆ operator[]() [1/2]
const int & mazes::distances::operator[] |
( |
const std::shared_ptr< cell > & | cell | ) |
const |
|
inlinenoexcept |
Accesses the value associated with a given cell in a shared pointer.
- Parameters
-
cell | A shared pointer to the cell whose associated value is to be accessed. |
- Returns
- A constant reference to the integer value associated with the specified cell.
◆ operator[]() [2/2]
int & mazes::distances::operator[] |
( |
const std::shared_ptr< cell > & | cell | ) |
|
|
inlinenoexcept |
Overloaded operator to access the distance of a cell.
- Parameters
-
cell | A shared pointer to the cell whose distance is to be accessed. |
- Returns
- A reference to the integer distance associated with the specified cell.
◆ set()
void mazes::distances::set |
( |
std::shared_ptr< cell > | cell, |
|
|
int | distance ) |
|
noexcept |
Sets the distance of a cell in the distances object.
- Parameters
-
cell | A shared pointer to the cell whose distance is to be set. |
The documentation for this class was generated from the following file: