20 template <
size_t K,
size_t E,
typename T =
double,
typename D =
double>
23 template <
size_t K,
size_t E,
typename T =
double,
typename D =
double>
27 KDTreeNode(
const std::vector<T>& pt,
const std::vector<D>& data) :
28 left(NULL), right(NULL)
31 for(ii=0; ii<K && ii<pt.size(); ii++)
36 for(ii=0; ii<E && ii<data.size(); ii++)
42 KDTreeNode(
size_t plen,
const T* pt,
size_t dlen,
const D* data) :
43 left(NULL), right(NULL)
46 for(ii=0; ii<K && ii<plen; ii++)
51 for(ii=0; ii<E && ii<dlen; ii++)
78 template <
size_t K,
size_t E,
typename T,
typename D>
86 KDTree() : m_built(false),m_treehead(NULL) { };
89 m_allnodes = std::move(other.m_allnodes);
90 m_built = other.m_built;
91 m_treehead = other.m_treehead;
92 other.m_allnodes.clear();
97 throw "Copy Constructor Not Yet Implemented";
101 while(!m_allnodes.empty()) {
102 delete m_allnodes.back() ;
103 m_allnodes.pop_back();
114 void insert(
const std::vector<T>& pt,
const std::vector<D>& data);
125 void insert(
size_t plen,
const T* pt,
size_t dlen,
const D* data);
141 std::list<const KDTreeNode<K,E,T,D>*>
withindist(
const std::vector<T>& pt,
double dist)
const;
142 std::list<const KDTreeNode<K,E,T,D>*>
withindist(
size_t len,
const T* pt,
double dist)
const;
153 std::vector<KDTreeNode<K,E,T,D>*> m_allnodes;
159 const T* pt,
double& distsq)
const;
161 std::list<const KDTreeNode<K,E,T,D>*> withindist_help(
size_t depth,
172 #include "kdtree.txx"
const KDTreeNode< K, E, T, D > * nearest(const std::vector< T > &pt, double &dist) const
KDTreeNode(size_t plen, const T *pt, size_t dlen, const D *data)
std::list< const KDTreeNode< K, E, T, D > * > withindist(const std::vector< T > &pt, double dist) const
void clear()
Remove all elements.
void insert(const std::vector< T > &pt, const std::vector< D > &data)
Insert a node (note that this is not dynamic, new nodes won't be found by search until build() is cal...
KDTreeNode(const std::vector< T > &pt, const std::vector< D > &data)
void build()
Create Tree, until this is called search won't find anything.
KDTree(const KDTree &other)