float facehash::search(vec ¢er, geoiterateface &itt) { FP best = itt.initaldist(); FP curr; qcell *next,*consider; pqueue<qcellptr> q; longset ls; q.add(next = tocell(center,ls)); FP currdist = next->celldist; if (level==0) numq++; int p,i; // first take care of the "patches" in toadd int pos = hashfn(next->i,false); if (toadd.length()>0 && (pos == -1 || storage[pos].contents==NULL || storage[pos].contents->length()<toadd.length())) { addall(); } else { for(i=0;i<toadd.length();i++) { nums++; curr = itt.process(toadd[i]); if (curr<best) best = curr; } } while(q.size()>0) { next = q.head().p; q.remove(0); currdist = next->celldist; if (currdist>best) { delete next; break; } p = hashfn(next->i,false); if (p!=-1) { if (storage[p].contents) { for(i=0;i<storage[p].contents->length();i++) { nums++; curr = itt.process((*(storage[p].contents))[i]); if (curr<best) best = curr; if (curr<currdist) break; } } else { curr = storage[p].subhash->search(center,itt); if (curr<best) best = curr; } if (best<currdist) break; } for(i=0;i<DIM;i++) { if ((consider=tocell(center,next->i,i,-1,ls))!=NULL) { q.add(consider); } if ((consider=tocell(center,next->i,i,1,ls))!=NULL) { q.add(consider); } } delete next; } for(i=0;i<q.size();i++) delete q.nth(i).p; return best; }
void stat_update_second_stats(void) { int *last_sec = stat_per_sec_counters; stat_per_sec_counters = stat_sec_counters; stat_sec_counters = to_zero_counters; stat_total_seconds++; addall( stat_total_counters, last_sec ); memset( last_sec, 0, C_SIZE ); to_zero_counters = last_sec; }