find_nearest_nth

Paul Harris paulharris at computer.org
Fri Jul 11 00:32:38 UTC 2008


I use a find_nearest_if() call, and pass a functor that confirms that the
node is NOT the target node.

eg, you could check it against a pointer, or in this case an ID.
you have to be careful with the pointer approach as you have to be careful
to find the right pointer (the address of the node that is stored in the
tree) ...

eg with id
struct not_me
{
  int id;
  not_me(int id) : id(id) {}
  bool operator()( Node const& n ) const { return n.id != id; }
};

found = kdtree.find_nearest_if( ... , not_me(target.id) );

2008/7/11 Gonsolo <gonsolo at gmail.com>:

> If I want to search for the nearest neighbour of an _exisiting_ node in
> libkdtree I currently have to do something like:
>
> nearest = kdtree.find_nearest(...);
> tmp = nearest;
> kdtree.erase( nearest );
> found = kdtree.find_nearest(...);
> tree.insert( tmp );
> return found;
>
> Is there a better method?
>
> g
>
> _______________________________________________
> libkdtree-devel mailing list
> libkdtree-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/libkdtree-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/libkdtree-devel/attachments/20080711/c718682f/attachment.htm 


More information about the libkdtree-devel mailing list