alternative title:
implement min heap faster std::priority_queue
.
grpof gave me:
time seconds seconds calls s/call s/call name
84.12 105.54 105.54 320000 0.00 0.00 _zn3rkdi24division_euclidean_spaceifee2nnejrkst6vectorifsaifeerkfrs3_ist4pairifiesaisb_eeriipjrst14priority_queueist5tupleijfiiees3_isj_saisj_eest7greaterisj_ees9_rkjs7_s7_i
which believe std::priority_queue
used in project. 'division_euclidean_space' part confuses me, since it's class/file not used more in project.
here use exactly:
/** * min_heap std::priority_queue, * std::greater parameter. */ typedef std::priority_queue<std::tuple<float, int, int>, std::vector<std::tuple<float, int, int> >, std::greater<std::tuple<float, int, int> > > min_heap;
i use first element key comparison.
and 1 can see in repo, create 1 min_heap
, use in 2 parts:
if(...) { branch.push(std::make_tuple(new_dist, other_child_i, tree_i)); }
and
while (branch.size()) { std::tie(new_mindist, node_i, tree_i) = branch.top(); branch.pop(); ... }
i feel if replace data structure else, project may run bit faster (super duper great). ideas?
i push items in heap while, pop 1 , push other items , on. of times stop condition, not when heap gets empty.
http://demangler.com translated function into: (indented me)
rkd<division_euclidean_space<float> >::nn( unsigned int, std::vector<float, std::allocator<float> > const&, float const&, std::vector<std::pair<float, int>, std::allocator<std::pair<float, int> > >&, int&, int, unsigned int*, std::priority_queue<std::tuple<float, int, int>, std::vector<std::tuple<float, int, int>, std::allocator<std::tuple<float, int, int> > >, std::greater<std::tuple<float, int, int> > >&, float const&, unsigned int const&, std::vector<float, std::allocator<float> > const&, std::vector<float, std::allocator<float> > const&, int)
i don't know nn
does, suppose lot more priority queue operations.