Using vector instead of deque for path unpacking
This commit is contained in:
parent
00ed039621
commit
cb6104e0ac
@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
std::vector<NodeID> alternativePath;
|
std::vector<NodeID> alternativePath;
|
||||||
std::vector<NodeID> viaNodeCandidates;
|
std::vector<NodeID> viaNodeCandidates;
|
||||||
std::deque <NodeID> packedShortestPath;
|
std::vector <NodeID> packedShortestPath;
|
||||||
std::vector<PreselectedNode> nodesThatPassPreselection;
|
std::vector<PreselectedNode> nodesThatPassPreselection;
|
||||||
|
|
||||||
HeapPtr & forwardHeap = super::_queryData.forwardHeap;
|
HeapPtr & forwardHeap = super::_queryData.forwardHeap;
|
||||||
@ -161,7 +161,7 @@ private:
|
|||||||
inline void retrievePackedViaPath(const HeapPtr & _forwardHeap1, const HeapPtr & _backwardHeap1, const HeapPtr & _forwardHeap2, const HeapPtr & _backwardHeap2,
|
inline void retrievePackedViaPath(const HeapPtr & _forwardHeap1, const HeapPtr & _backwardHeap1, const HeapPtr & _forwardHeap2, const HeapPtr & _backwardHeap2,
|
||||||
const NodeID s_v_middle, const NodeID v_t_middle, std::vector<_PathData> & unpackedPath) {
|
const NodeID s_v_middle, const NodeID v_t_middle, std::vector<_PathData> & unpackedPath) {
|
||||||
//unpack [s,v)
|
//unpack [s,v)
|
||||||
std::deque<NodeID> packed_s_v_path, packed_v_t_path;
|
std::vector<NodeID> packed_s_v_path, packed_v_t_path;
|
||||||
super::RetrievePackedPathFromHeap(_forwardHeap1, _backwardHeap2, s_v_middle, packed_s_v_path);
|
super::RetrievePackedPathFromHeap(_forwardHeap1, _backwardHeap2, s_v_middle, packed_s_v_path);
|
||||||
packed_s_v_path.resize(packed_s_v_path.size()-1);
|
packed_s_v_path.resize(packed_s_v_path.size()-1);
|
||||||
//unpack [v,t]
|
//unpack [v,t]
|
||||||
@ -171,7 +171,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void computeLengthAndSharingOfViaPath(const PreselectedNode& node, int *lengthOfViaPath, int *sharingOfViaPath,
|
inline void computeLengthAndSharingOfViaPath(const PreselectedNode& node, int *lengthOfViaPath, int *sharingOfViaPath,
|
||||||
const int offset, const std::deque<NodeID> & packedShortestPath) {
|
const int offset, const std::vector<NodeID> & packedShortestPath) {
|
||||||
//compute and unpack <s,..,v> and <v,..,t> by exploring search spaces from v and intersecting against queues
|
//compute and unpack <s,..,v> and <v,..,t> by exploring search spaces from v and intersecting against queues
|
||||||
//only half-searches have to be done at this stage
|
//only half-searches have to be done at this stage
|
||||||
super::_queryData.InitializeOrClearSecondThreadLocalStorage();
|
super::_queryData.InitializeOrClearSecondThreadLocalStorage();
|
||||||
@ -181,8 +181,8 @@ private:
|
|||||||
HeapPtr & newForwardHeap = super::_queryData.forwardHeap2;
|
HeapPtr & newForwardHeap = super::_queryData.forwardHeap2;
|
||||||
HeapPtr & newBackwardHeap = super::_queryData.backwardHeap2;
|
HeapPtr & newBackwardHeap = super::_queryData.backwardHeap2;
|
||||||
|
|
||||||
std::deque < NodeID > packed_s_v_path;
|
std::vector < NodeID > packed_s_v_path;
|
||||||
std::deque < NodeID > packed_v_t_path;
|
std::vector < NodeID > packed_v_t_path;
|
||||||
|
|
||||||
std::vector<NodeID> partiallyUnpackedShortestPath;
|
std::vector<NodeID> partiallyUnpackedShortestPath;
|
||||||
std::vector<NodeID> partiallyUnpackedViaPath;
|
std::vector<NodeID> partiallyUnpackedViaPath;
|
||||||
@ -258,8 +258,8 @@ private:
|
|||||||
//finished partial unpacking spree! Amount of sharing is stored to appropriate poiner variable
|
//finished partial unpacking spree! Amount of sharing is stored to appropriate poiner variable
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int approximateAmountOfSharing(const NodeID middleNodeIDOfAlternativePath, HeapPtr & _forwardHeap, HeapPtr & _backwardHeap, const std::deque<NodeID> & packedShortestPath) {
|
inline int approximateAmountOfSharing(const NodeID middleNodeIDOfAlternativePath, HeapPtr & _forwardHeap, HeapPtr & _backwardHeap, const std::vector<NodeID> & packedShortestPath) {
|
||||||
std::deque<NodeID> packedAlternativePath;
|
std::vector<NodeID> packedAlternativePath;
|
||||||
super::RetrievePackedPathFromHeap(_forwardHeap, _backwardHeap, middleNodeIDOfAlternativePath, packedAlternativePath);
|
super::RetrievePackedPathFromHeap(_forwardHeap, _backwardHeap, middleNodeIDOfAlternativePath, packedAlternativePath);
|
||||||
|
|
||||||
if(packedShortestPath.size() < 2 || packedAlternativePath.size() < 2)
|
if(packedShortestPath.size() < 2 || packedAlternativePath.size() < 2)
|
||||||
@ -336,8 +336,8 @@ private:
|
|||||||
|
|
||||||
//conduct T-Test
|
//conduct T-Test
|
||||||
inline bool viaNodeCandidatePasses_T_Test( HeapPtr& existingForwardHeap, HeapPtr& existingBackwardHeap, HeapPtr& newForwardHeap, HeapPtr& newBackwardHeap, const RankedCandidateNode& candidate, const int offset, const int lengthOfShortestPath, int * lengthOfViaPath, NodeID * s_v_middle, NodeID * v_t_middle) {
|
inline bool viaNodeCandidatePasses_T_Test( HeapPtr& existingForwardHeap, HeapPtr& existingBackwardHeap, HeapPtr& newForwardHeap, HeapPtr& newBackwardHeap, const RankedCandidateNode& candidate, const int offset, const int lengthOfShortestPath, int * lengthOfViaPath, NodeID * s_v_middle, NodeID * v_t_middle) {
|
||||||
std::deque < NodeID > packed_s_v_path;
|
std::vector < NodeID > packed_s_v_path;
|
||||||
std::deque < NodeID > packed_v_t_path;
|
std::vector < NodeID > packed_v_t_path;
|
||||||
|
|
||||||
super::_queryData.InitializeOrClearSecondThreadLocalStorage();
|
super::_queryData.InitializeOrClearSecondThreadLocalStorage();
|
||||||
*s_v_middle = UINT_MAX;
|
*s_v_middle = UINT_MAX;
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void UnpackPath(std::deque<NodeID> & packedPath, std::vector<_PathData> & unpackedPath) const {
|
inline void UnpackPath(std::vector<NodeID> & packedPath, std::vector<_PathData> & unpackedPath) const {
|
||||||
|
|
||||||
const unsigned sizeOfPackedPath = packedPath.size();
|
const unsigned sizeOfPackedPath = packedPath.size();
|
||||||
std::stack<std::pair<NodeID, NodeID> > recursionStack;
|
std::stack<std::pair<NodeID, NodeID> > recursionStack;
|
||||||
@ -204,13 +204,15 @@ public:
|
|||||||
unpackedPath.push_back(t);
|
unpackedPath.push_back(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RetrievePackedPathFromHeap(const typename QueryDataT::HeapPtr & _fHeap, const typename QueryDataT::HeapPtr & _bHeap, const NodeID middle, std::deque<NodeID>& packedPath) {
|
inline void RetrievePackedPathFromHeap(const typename QueryDataT::HeapPtr & _fHeap, const typename QueryDataT::HeapPtr & _bHeap, const NodeID middle, std::vector<NodeID>& packedPath) {
|
||||||
NodeID pathNode = middle;
|
NodeID pathNode = middle;
|
||||||
while(pathNode != _fHeap->GetData(pathNode).parent) {
|
while(pathNode != _fHeap->GetData(pathNode).parent) {
|
||||||
pathNode = _fHeap->GetData(pathNode).parent;
|
pathNode = _fHeap->GetData(pathNode).parent;
|
||||||
packedPath.push_front(pathNode);
|
packedPath.push_back(pathNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::reverse(packedPath.begin(), packedPath.end());
|
||||||
|
|
||||||
packedPath.push_back(middle);
|
packedPath.push_back(middle);
|
||||||
pathNode = middle;
|
pathNode = middle;
|
||||||
while (pathNode != _bHeap->GetData(pathNode).parent){
|
while (pathNode != _bHeap->GetData(pathNode).parent){
|
||||||
|
@ -47,8 +47,8 @@ public:
|
|||||||
bool searchFrom2ndStartNode(true);
|
bool searchFrom2ndStartNode(true);
|
||||||
NodeID middle1 = ( NodeID ) UINT_MAX;
|
NodeID middle1 = ( NodeID ) UINT_MAX;
|
||||||
NodeID middle2 = ( NodeID ) UINT_MAX;
|
NodeID middle2 = ( NodeID ) UINT_MAX;
|
||||||
std::deque<NodeID> packedPath1;
|
std::vector<NodeID> packedPath1;
|
||||||
std::deque<NodeID> packedPath2;
|
std::vector<NodeID> packedPath2;
|
||||||
|
|
||||||
typename QueryDataT::HeapPtr & forwardHeap = super::_queryData.forwardHeap;
|
typename QueryDataT::HeapPtr & forwardHeap = super::_queryData.forwardHeap;
|
||||||
typename QueryDataT::HeapPtr & backwardHeap = super::_queryData.backwardHeap;
|
typename QueryDataT::HeapPtr & backwardHeap = super::_queryData.backwardHeap;
|
||||||
@ -141,8 +141,8 @@ public:
|
|||||||
// INFO("middle1: " << middle1);
|
// INFO("middle1: " << middle1);
|
||||||
|
|
||||||
//Unpack paths if they exist
|
//Unpack paths if they exist
|
||||||
std::deque<NodeID> temporaryPackedPath1;
|
std::vector<NodeID> temporaryPackedPath1;
|
||||||
std::deque<NodeID> temporaryPackedPath2;
|
std::vector<NodeID> temporaryPackedPath2;
|
||||||
if(INT_MAX != _localUpperbound1) {
|
if(INT_MAX != _localUpperbound1) {
|
||||||
super::RetrievePackedPathFromHeap(forwardHeap, backwardHeap, middle1, temporaryPackedPath1);
|
super::RetrievePackedPathFromHeap(forwardHeap, backwardHeap, middle1, temporaryPackedPath1);
|
||||||
// INFO("temporaryPackedPath1 ends with " << *(temporaryPackedPath1.end()-1) );
|
// INFO("temporaryPackedPath1 ends with " << *(temporaryPackedPath1.end()-1) );
|
||||||
|
Loading…
Reference in New Issue
Block a user