Algorithm
Development Kit 1.0

algs.model.kdtree
Class KDFactory

java.lang.Object
  extended by algs.model.kdtree.KDFactory

public class KDFactory
extends java.lang.Object

Produces a KD-tree from a given input set using recursive median approach.

Note that we take care to construct the associated Hypercube regions with each node to ensure the integrity of the regions; without these regions being properly set, there is no way to "drain" the children of a subtree when a query wholly contains a subtree's region.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Constructor Summary
KDFactory()
           
 
Method Summary
static KDTree generate(IMultiPoint[] points)
          Generate a KDTree from the given array of points.
static KDTree generate(IPoint[] points)
          Generate a KDTree from the given array of IPoints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KDFactory

public KDFactory()
Method Detail

generate

public static KDTree generate(IMultiPoint[] points)
Generate a KDTree from the given array of points.

If points is null, then return null since the dimensionality is unknown.

All points must have the same dimensionality, otherwise strange behavior may occur. Also, this method is not re-entrant, since the comparators array is regenerated upon each invocation, thus we mark the method as 'synchronized'.

Parameters:
points - points which are to be used as source to generate KDTree.

generate

public static KDTree generate(IPoint[] points)
Generate a KDTree from the given array of IPoints. If underlying objects in points[] already implement IMultiPoint, then good. Otherwise a new array of TwoDPoint objects is constructed to be passed into the generate method on an IMultiPoint[] array (where the values for these TwoDPoints are extracted from the X and Y coordinate values of the IPoint objects).

Parameters:
points -

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.