I use a find_nearest_if() call, and pass a functor that confirms that the node is NOT the target node.<br><br>eg, you could check it against a pointer, or in this case an ID.<br>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) ...<br>
<br>eg with id<br>struct not_me<br>{<br>&nbsp; int id;<br>&nbsp; not_me(int id) : id(id) {}<br>&nbsp; bool operator()( Node const&amp; n ) const { return <a href="http://n.id">n.id</a> != id; }<br>};<br><br>found = kdtree.find_nearest_if( ... , not_me(<a href="http://target.id">target.id</a>) );<br>
<br><div class="gmail_quote">2008/7/11 Gonsolo &lt;<a href="mailto:gonsolo@gmail.com">gonsolo@gmail.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If I want to search for the nearest neighbour of an _exisiting_ node in<br>
libkdtree I currently have to do something like:<br>
<br>
nearest = kdtree.find_nearest(...);<br>
tmp = nearest;<br>
kdtree.erase( nearest );<br>
found = kdtree.find_nearest(...);<br>
tree.insert( tmp );<br>
return found;<br>
<br>
Is there a better method?<br>
<br>
g<br>
<br>
_______________________________________________<br>
libkdtree-devel mailing list<br>
<a href="mailto:libkdtree-devel@lists.alioth.debian.org">libkdtree-devel@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/mailman/listinfo/libkdtree-devel" target="_blank">http://lists.alioth.debian.org/mailman/listinfo/libkdtree-devel</a><br>
</blockquote></div><br>