A class that manages distances associated with cells in a grid.
More...
#include <distances.h>
|
| distances (int32_t root_index) |
| Constructor that initializes the distances object with a given root index.
|
|
int & | operator[] (int32_t index) noexcept |
| Overloaded operator to access the distance of a cell by index.
|
|
const int & | operator[] (int32_t index) const noexcept |
| Accesses the value associated with a given cell index.
|
|
void | set (int32_t index, int distance) noexcept |
| Sets the distance of a cell by index.
|
|
bool | contains (int32_t index) const noexcept |
| Checks if a given cell index is contained in the distances object.
|
|
std::shared_ptr< distances > | path_to (std::unique_ptr< grid_interface > const &g, int32_t goal_index) const noexcept |
| Computes the shortest path to a goal cell index within a distances object.
|
|
std::pair< int32_t, int > | max () const noexcept |
| Computes the maximum distance and cell index in a distances object.
|
|
void | collect_keys (std::vector< int32_t > &indices) const noexcept |
| Collects all cell indices stored in the distances object.
|
|
A class that manages distances associated with cells in a grid.
This class provides functionality to initialize distances from a root cell,
◆ distances()
mazes::distances::distances |
( |
int32_t | root_index | ) |
|
|
explicit |
Constructor that initializes the distances object with a given root index.
- Parameters
-
root_index | The index of the root cell used to initialize the distances object. |
◆ collect_keys()
void mazes::distances::collect_keys |
( |
std::vector< int32_t > & | indices | ) |
const |
|
noexcept |
Collects all cell indices stored in the distances object.
- Parameters
-
indices | A reference to a vector to store the collected indices. |
◆ contains()
bool mazes::distances::contains |
( |
int32_t | index | ) |
const |
|
noexcept |
Checks if a given cell index is contained in the distances object.
- Parameters
-
index | The index of the cell to check for containment. |
◆ max()
std::pair< int32_t, int > mazes::distances::max |
( |
| ) |
const |
|
noexcept |
Computes the maximum distance and cell index in a distances object.
- Returns
- A pair containing the index of the cell with the maximum distance and the distance value.
◆ operator[]() [1/2]
const int & mazes::distances::operator[] |
( |
int32_t | index | ) |
const |
|
noexcept |
Accesses the value associated with a given cell index.
- Parameters
-
index | The index of the cell whose associated value is to be accessed. |
- Returns
- A constant reference to the integer value associated with the specified cell index.
◆ operator[]() [2/2]
int & mazes::distances::operator[] |
( |
int32_t | index | ) |
|
|
noexcept |
Overloaded operator to access the distance of a cell by index.
- Parameters
-
index | The index of the cell whose distance is to be accessed. |
- Returns
- A reference to the integer distance associated with the specified cell index.
◆ path_to()
std::shared_ptr< distances > mazes::distances::path_to |
( |
std::unique_ptr< grid_interface > const & | g, |
|
|
int32_t | goal_index ) const |
|
noexcept |
Computes the shortest path to a goal cell index within a distances object.
- Parameters
-
goal_index | The index of the goal cell. |
grid | A reference to the grid object for retrieving cell pointers. |
- Returns
- A shared pointer to a distances object representing the path.
◆ set()
void mazes::distances::set |
( |
int32_t | index, |
|
|
int | distance ) |
|
noexcept |
Sets the distance of a cell by index.
- Parameters
-
index | The index of the cell whose distance is to be set. |
The documentation for this class was generated from the following file: