MiniGame-Madness
Public Member Functions | Public Attributes | List of all members
MazeNode Struct Reference

A struct that represents the nodes in the graph of the maze. More...

#include <maze.h>

Public Member Functions

 MazeNode ()
 Default constructor for MazeNode. More...
 
void addNeighbor (MazeNode *node, Direction direction)
 Add a neighboring node with a direction. More...
 
void removeNeighbor (Direction direction)
 Remove a neighboring node based on a direction. More...
 
MazeNodegetNeighbor (Direction direction) const
 Get the neighboring node in a given direction. More...
 
std::map< Direction, MazeNode * > getNeighbors () const
 Get all neighboring nodes. More...
 

Public Attributes

std::map< Direction, MazeNode * > neighbors
 

Detailed Description

A struct that represents the nodes in the graph of the maze.

The default is each neighbor is set to nullptr.

Constructor & Destructor Documentation

◆ MazeNode()

MazeNode::MazeNode ( )
inline

Default constructor for MazeNode.

Initialize the MazeNode with the type NONE

Member Function Documentation

◆ addNeighbor()

void MazeNode::addNeighbor ( MazeNode node,
Direction  direction 
)
inline

Add a neighboring node with a direction.

Parameters
node- The node to add as a neighbor.
direction- The direction of the neighboring node.
Exceptions
runtime_errorif the neighbor already exists in the given direction.

◆ getNeighbor()

MazeNode* MazeNode::getNeighbor ( Direction  direction) const
inline

Get the neighboring node in a given direction.

Parameters
direction- The direction of the neighboring node.
Returns
The neighboring node in the given direction, or nullptr if not found.

◆ getNeighbors()

std::map<Direction, MazeNode*> MazeNode::getNeighbors ( ) const
inline

Get all neighboring nodes.

Returns
A map of directions to neighboring nodes.

◆ removeNeighbor()

void MazeNode::removeNeighbor ( Direction  direction)
inline

Remove a neighboring node based on a direction.

Parameters
direction- The direction of the neighboring node.
Exceptions
runtime_errorif the neighbor is not found in the given direction.

Member Data Documentation

◆ neighbors

std::map<Direction, MazeNode*> MazeNode::neighbors

A map of directions to neighboring nodes, using raw pointers since neighbors don't own each other.


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