find_nearest_nth

Paul Harris paulharris at computer.org
Fri Jul 11 02:04:18 UTC 2008


node is whatever you store in the tree...

so in this case its pretty easy

struct not_me
{
shared_ptr<A> me;
 not_me(shared_ptr<A> m) : me(m) {}

 bool operator()( shared_ptr<A> const& n ) const { return n != me; }
};


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

> Hi!
>
> Paul Harris schrieb:
>
>> 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) );
>>
>
> Thank you very much. I tried that but I still do not get it.
> What is that Node? In kdtree's source I find _Node.
>
> I have something like:
>
> class A {};
>
> typedef KDTree::KDTree<3, boost::shared_ptr<A>,
> std::pointer_to_binary_function< shared_ptr<A>,int,double> > kdtree;
>
> g
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/libkdtree-devel/attachments/20080711/f91f24eb/attachment.htm 


More information about the libkdtree-devel mailing list