Single dimension search

martin f krafft madduck at debian.org
Fri Jan 18 19:38:04 UTC 2008


also sprach Andrew Leung <anwleung at gmail.com> [2008.01.18.2005 +0100]:
> For example, test_kdtree.cpp creates triplets and searches the tree 
> using other triplets as comparators. Is there a way I can search using 1 
> or 2 of the triplet fields, not all three? Such as, find all triplets 
> with a first dimension value of 5. Thanks for your help.

Kd-Trees are not made for this sort of search, but since you get to
specify your own comparator, it's simple to do, I'd say:

Modifying test_kdtree.cpp:

inline bool operator==(triplet const& A, triplet const& B) {
  return A.d[0] == B.d[0];
}

-- 
 .''`.   martin f. krafft <madduck at debian.org>
: :'  :  proud Debian developer, author, administrator, and user
`. `'`   http://people.debian.org/~madduck - http://debiansystem.info
  `-  Debian - when you have better things to do than fixing systems
 
a woman is an occasional pleasure
but a cigar is always a smoke.
                                                       -- groucho marx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
Url : http://lists.alioth.debian.org/pipermail/libkdtree-devel/attachments/20080118/4b7ee684/attachment.pgp 


More information about the libkdtree-devel mailing list