Maze Builder Docs 8.2.1
Loading...
Searching...
No Matches
mazes::distances Class Reference

A class that manages distances associated with cells in a grid. More...

#include <distances.h>

Public Member Functions

 distances (std::int32_t root_index)
 Constructor that initializes the distances object with a given root index.
 
int & operator[] (std::int32_t index) noexcept
 Overloaded operator to access the distance of a cell by index.
 
const int & operator[] (std::int32_t index) const noexcept
 Accesses the value associated with a given cell index.
 
void set (std::int32_t index, int distance) noexcept
 Sets the distance of a cell by index.
 
bool contains (std::int32_t index) const noexcept
 Checks if a given cell index is contained in the distances object.
 
std::pair< std::int32_t, int > max () const noexcept
 Computes the maximum distance and cell index in a distances object.
 
void collect_keys (std::vector< std::int32_t > &indices) const noexcept
 Collects all cell indices stored in the distances object.
 

Static Public Member Functions

static std::shared_ptr< distancespath_to (grid_interface *g, std::int32_t start_index, std::int32_t goal_index) noexcept
 Computes the shortest path to a goal cell index within a distances object.
 

Detailed Description

A class that manages distances associated with cells in a grid.

This class provides functionality to initialize distances from a root cell,

Constructor & Destructor Documentation

◆ distances()

mazes::distances::distances ( std::int32_t root_index)
explicit

Constructor that initializes the distances object with a given root index.

Parameters
root_indexThe index of the root cell used to initialize the distances object.

Member Function Documentation

◆ collect_keys()

void mazes::distances::collect_keys ( std::vector< std::int32_t > & indices) const
noexcept

Collects all cell indices stored in the distances object.

Parameters
indicesA reference to a vector to store the collected indices.

◆ contains()

bool mazes::distances::contains ( std::int32_t index) const
nodiscardnoexcept

Checks if a given cell index is contained in the distances object.

Parameters
indexThe index of the cell to check for containment.

◆ max()

std::pair< std::int32_t, int > mazes::distances::max ( ) const
nodiscardnoexcept

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[] ( std::int32_t index) const
noexcept

Accesses the value associated with a given cell index.

Parameters
indexThe 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[] ( std::int32_t index)
noexcept

Overloaded operator to access the distance of a cell by index.

Parameters
indexThe 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()

static std::shared_ptr< distances > mazes::distances::path_to ( grid_interface * g,
std::int32_t start_index,
std::int32_t goal_index )
staticnoexcept

Computes the shortest path to a goal cell index within a distances object.

Parameters
gA pointer to the grid
start_indexThe index of the starting cell.
goal_indexThe index of the goal cell.
Returns
A shared pointer to a distances object representing the path.

◆ set()

void mazes::distances::set ( std::int32_t index,
int distance )
noexcept

Sets the distance of a cell by index.

Parameters
indexThe index of the cell whose distance is to be set.
distanceThe distance value to be set for the specified cell index.

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