jlblancoc / nanoflann

nanoflann: a C++11 header-only library for Nearest Neighbor (NN) search with KD-trees

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add KDTree into a hashset/hashmap?

JiayingGaoo opened this issue · comments

commented

Hi there,
Thanks for your great and impressive work!
I am new to nanoflann. I want to add some kdtree into a hashset, just like below:

`
using KDTree = KDTreeSingleIndexAdaptor<L2_Simple_Adaptor<double, Point2D>, Point2D, 2/* dim */>;
KDTree kd0 = KDTree(2, cloud0);
KDTree kd1 = KDTree(2, cloud1);
KDTree kd2 = KDTree(2, cloud2);

unordered_set trees = {kd0, kd1, kd2};
`

Then, a mistake is encountered:
error C2440: 'initializing': cannot convert from 'initializer list' to 'std::unordered_set<KDTRee,std::hash,std::equal_to,std::allocator>'

What can i do to fix it, thanks a lot!

commented

Maybe I need to construct the hashset by the pointers, such like: unordered_set<KDTree*>?

commented

Thanks, I solve it.

Cool! Yeah, using pointers is a possible solution. Another is creating your own overload of hash.
Read, for example, this SO thread.