类 KDTree
- java.lang.Object
-
- org.meteoinfo.math.stats.kde.kdtree.KDTree
-
- 所有已实现的接口:
java.io.Serializable
public class KDTree extends java.lang.Object implements java.io.SerializableKDTree is a class supporting KD-tree insertion, deletion, equality search, range search, and nearest neighbor(s) using double-precision floating-point keys. Splitting dimension is chosen naively, by depth modulo K. Semantics are as follows:- Two different keys containing identical numbers should retrieve the same
value from a given KD-tree. Therefore keys are cloned when a node is
inserted.
- As with Hashtables, values inserted into a KD-tree are not cloned. Modifying a value between insertion and retrieval will therefore modify the value stored in the tree.
- 从以下版本开始:
- JDK1.2
- 版本:
- %I%, %G%
- 作者:
- Simon Levy, Bjoern Heckel
- 另请参阅:
- 序列化表格
-
-
构造器概要
构造器 构造器 说明 KDTree(int k)Creates a KD-tree with specified number of dimensions.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voiddelete(double[] key)Delete a node from a KD-tree.voidinsert(double[] key, java.lang.Object value)Insert a node in a KD-tree.java.lang.Objectnearest(double[] key)Find KD-tree node whose key is nearest neighbor to key.java.lang.Object[]nearest(double[] key, int n)Find KD-tree nodes whose keys are n nearest neighbors to key.java.lang.Object[]range(double[] lowk, double[] uppk)Range search in a KD-tree.java.lang.Objectsearch(double[] key)Find KD-tree node whose key is identical to key.java.lang.StringtoString()
-
-
-
方法详细资料
-
insert
public void insert(double[] key, java.lang.Object value)Insert a node in a KD-tree. Uses algorithm translated from 352.ins.c of@Book{GonnetBaezaYates1991, author = {G.H. Gonnet and R. Baeza-Yates}, title = {Handbook of Algorithms and Data Structures}, publisher = {Addison-Wesley}, year = {1991} }- 参数:
key- key for KD-tree nodevalue- value at that key- 抛出:
KeySizeException- if key.length mismatches KKeyDuplicateException- if key already in tree
-
search
public java.lang.Object search(double[] key)
Find KD-tree node whose key is identical to key. Uses algorithm translated from 352.srch.c of Gonnet & Baeza-Yates.- 参数:
key- key for KD-tree node- 返回:
- object at key, or null if not found
- 抛出:
KeySizeException- if key.length mismatches K
-
delete
public void delete(double[] key)
Delete a node from a KD-tree. Instead of actually deleting node and rebuilding tree, marks node as deleted. Hence, it is up to the caller to rebuild the tree as needed for efficiency.- 参数:
key- key for KD-tree node- 抛出:
KeySizeException- if key.length mismatches KKeyMissingException- if no node in tree has key
-
nearest
public java.lang.Object nearest(double[] key)
Find KD-tree node whose key is nearest neighbor to key. Implements the Nearest Neighbor algorithm (Table 6.4) of@techreport{AndrewMooreNearestNeighbor, author = {Andrew Moore}, title = {An introductory tutorial on kd-trees}, institution = {Robotics Institute, Carnegie Mellon University}, year = {1991}, number = {Technical Report No. 209, Computer Laboratory, University of Cambridge}, address = {Pittsburgh, PA} }- 参数:
key- key for KD-tree node- 返回:
- object at node nearest to key, or null on failure
- 抛出:
KeySizeException- if key.length mismatches K
-
nearest
public java.lang.Object[] nearest(double[] key, int n)Find KD-tree nodes whose keys are n nearest neighbors to key. Uses algorithm above. Neighbors are returned in ascending order of distance to key.- 参数:
key- key for KD-tree noden- how many neighbors to find- 返回:
- objects at node nearest to key, or null on failure
- 抛出:
KeySizeException- if key.length mismatches Kjava.lang.IllegalArgumentException- if n is negative or exceeds tree size
-
range
public java.lang.Object[] range(double[] lowk, double[] uppk)Range search in a KD-tree. Uses algorithm translated from 352.range.c of Gonnet & Baeza-Yates.- 参数:
lowk- lower-bounds for keyuppk- upper-bounds for key- 返回:
- array of Objects whose keys fall in range [lowk,uppk]
- 抛出:
KeySizeException- on mismatch among lowk.length, uppk.length, or K
-
toString
public java.lang.String toString()
- 覆盖:
toString在类中java.lang.Object
-
-