Skip to content

Commit f9b64be

Browse files
Add get_id() method to node class for unique identification
1 parent 75c063c commit f9b64be

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

include/a_star.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ namespace utils
1414
node(std::weak_ptr<node<Tp>> parent, const Tp &g_cost) noexcept : parent_node(std::move(parent)), g(g_cost) {}
1515
virtual ~node() = default;
1616

17+
/**
18+
* @brief Returns a unique identifier for the node.
19+
*
20+
* This function provides a way to uniquely identify each node instance.
21+
* The identifier is derived from the memory address of the node object.
22+
*
23+
* @return A uintptr_t representing the unique identifier of the node.
24+
*/
25+
[[nodiscard]] uintptr_t get_id() const noexcept { return reinterpret_cast<uintptr_t>(this); }
26+
1727
/**
1828
* @brief Returns a shared pointer to the parent node.
1929
*

0 commit comments

Comments
 (0)