kdtree< VALUE > Class Template Reference

List of all members.

Classes

struct  KDNode

Public Member Functions

 kdtree (unsigned int kdim, std::list< float * > *dataset, std::list< VALUE > *userset=NULL)
int size ()
int dim ()
bool empty ()
std::list< float * > * findDataset (float *datavec)
std::list< float * > * findDatasetInterval (float *min_datavec, float *max_datavec)
std::list< VALUE > * findUserset (float *datavec)
std::list< VALUE > * findUsersetInterval (float *min_datavec, float *max_datavec)
KDNodebuild (unsigned int kdim, unsigned int curlvl, unsigned int equaldims, std::list< float * > *dataset, std::list< VALUE > *userset=NULL)

Public Attributes

int kdim
KDNoderoot

template<class VALUE>
class kdtree< VALUE >


Constructor & Destructor Documentation

template<class VALUE>
kdtree< VALUE >::kdtree ( unsigned int  kdim,
std::list< float * > *  dataset,
std::list< VALUE > *  userset = NULL 
) [inline]

Constructs an immutable kd-tree of the given dimensionality (kdim) for the given dataset (and corresponding userset). Datavectors must be of dimension kdim.


Member Function Documentation

template<class VALUE>
KDNode* kdtree< VALUE >::build ( unsigned int  kdim,
unsigned int  curlvl,
unsigned int  equaldims,
std::list< float * > *  dataset,
std::list< VALUE > *  userset = NULL 
) [inline]

Constructs a KD-Tree of the given dimensionality (kdim) for the given dataset. Note that the pointers in the dataset are stored in the tree. The algorithm identifies equal dimensions and delivers optimized branches (throw/catch is used to return leafes upwards to the branch where the last difference in data was).

kdim : Dimensionality of datavectors. curlvl : Current level, should be 0 initialy. equaldims : Equal dimensions, should be 0 initialy. dataset: List of datavectors of dimension kdim to cluster. userset: Associated userdata/objects for each datavector (or userset == NULL <=> no userdata at all).

The function is roughly divided into:

  • Terminal case handling for leaves
  • Partitioning data into two sets left and right
  • Recursion for left sub-tree/partition
  • Recursion for right sub-tree/partition
template<class VALUE>
int kdtree< VALUE >::dim (  )  [inline]

Returns the number of dimensions a stored datavector has/must have.

template<class VALUE>
bool kdtree< VALUE >::empty (  )  [inline]

Returns true if the tree contains no data (as of now never).

template<class VALUE>
std::list<float*>* kdtree< VALUE >::findDataset ( float *  datavec  )  [inline]

Returns a list of similar datavectors to the given datavector note that when the list contains more than one datavector then they are all equal (at least within an epsilon). The returned list is freshly allocated (new'ed). To delete is caller responsibility.

template<class VALUE>
std::list<float*>* kdtree< VALUE >::findDatasetInterval ( float *  min_datavec,
float *  max_datavec 
) [inline]

Similar to findDataset(..) but finds datavectors near to the given interval. The returned list is freshly allocated (new'ed). To delete is caller responsibility.

template<class VALUE>
std::list<VALUE>* kdtree< VALUE >::findUserset ( float *  datavec  )  [inline]

Returns a list of associated userdata for similar datavectors to the given datavector note that when the list contains more than one userdata then the found datavectors where all equal (at least within an epsilon). The returned list is freshly allocated (new'ed). To delete is caller responsibility.

template<class VALUE>
std::list<VALUE>* kdtree< VALUE >::findUsersetInterval ( float *  min_datavec,
float *  max_datavec 
) [inline]

Similar to findUserset(..) but finds userdata for datavectors near to the given interval. The returned list is freshly allocated (new'ed). To delete is caller responsibility.

template<class VALUE>
int kdtree< VALUE >::size (  )  [inline]

Returns amount of (not necessarily unique) stored datavectors.


The documentation for this class was generated from the following file:

Generated on Thu Jan 28 14:11:05 2010 for Linwarrior 3D by  doxygen 1.6.1