added new assertins
added some temporary eval parts new helper methods worked on the walkers
This commit is contained in:
@@ -22,9 +22,10 @@ template <typename T> class Dijkstra {
|
||||
|
||||
public:
|
||||
|
||||
/** get the dijkstra-pendant for the given user-node */
|
||||
DijkstraNode<T>* getNode(const T& userNode) {
|
||||
return nodes[&userNode];
|
||||
/** get the dijkstra-pendant for the given user-node. null if none matches */
|
||||
DijkstraNode<T>* getNode(const T& userNode) const {
|
||||
auto it = nodes.find(&userNode);
|
||||
return (unlikely(it == nodes.end())) ? (nullptr) : (it->second);
|
||||
}
|
||||
|
||||
/** build shortest path from start to end using the provided wrapper-class */
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define DIJKSTRAPATH_H
|
||||
|
||||
#include "DijkstraStructs.h"
|
||||
#include <vector>
|
||||
|
||||
#include "../../Assertions.h"
|
||||
|
||||
/**
|
||||
* describes a dijkstra-generated path between end and start.
|
||||
@@ -20,15 +23,30 @@ public:
|
||||
/** ctor from end- to start-node */
|
||||
DijkstraPath(DijkstraNode<T>* end, DijkstraNode<T>* start) {
|
||||
|
||||
// sanity checks
|
||||
Assert::isNotNull(end, "end-node must not be null");
|
||||
Assert::isNotNull(start, "start-node must not be null");
|
||||
|
||||
// follow the path from the end to the start
|
||||
DijkstraNode<T>* curNode = end;
|
||||
while (curNode != start) {
|
||||
|
||||
// sanity check in case no path between start and end exists
|
||||
Assert::isNotNull(curNode, "there is not path between start and end. did you accidentially swap start and end?");
|
||||
|
||||
// append
|
||||
path.push_back(curNode);
|
||||
curNode = curNode->previous;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** allow iteration */
|
||||
decltype(path.begin()) begin() {return path.begin();}
|
||||
decltype(path.end()) end() {return path.end();}
|
||||
|
||||
|
||||
/** NANOFLANN: number of elements in the path */
|
||||
inline int kdtree_get_point_count() const {
|
||||
return path.size();
|
||||
|
||||
Reference in New Issue
Block a user