Skip to content

Commit

Permalink
heap scan for CPU version
Browse files Browse the repository at this point in the history
  • Loading branch information
imwithye committed Jun 20, 2014
1 parent 9fa0dc2 commit d1ad4c4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/Genie/Scan/CPUScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ using namespace std;
#include "UtlScan.h"
#include "DistFunc.h"


struct CompareTopNode {
bool operator()(const topNode& x, const topNode& y) const
{
return x.dis < y.dis;
}
};

class CPUScan {
public:
Expand Down Expand Up @@ -77,20 +82,21 @@ class CPUScan {


//compute the max value in this array
double maxd=-1; int idx=-1;
for(int r=0;r<k;r++){
if(res[r].dis >= maxd){

maxd=res[r].dis;
idx=r;

}
}
double maxd=res[0].dis; int idx=0;
// for(int r=0;r<k;r++){
// if(res[r].dis >= maxd){
//
// maxd=res[r].dis;
// idx=r;
//
// }
// }

//if smaller than maxd, replace
if(di<=maxd){
res[idx].dis = di; //_dist[idx]=di;
res[idx].idx = i; ////_index[idx]=i;
make_heap (res.begin(), res.end(), CompareTopNode());
}
}

Expand Down

0 comments on commit d1ad4c4

Please sign in to comment.