Class KDTree<T>
- All Implemented Interfaces:
Iterable<T>, EuclideanSpace, IterableRealInterval<T>, RealInterval, Typed<T>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final KDTreeImplprivate static final intprivate final KDTreeData<T> -
Constructor Summary
ConstructorsModifierConstructorDescription<L extends RealLocalizable><L extends RealLocalizable>Construct a KDTree from the elements in the given list.KDTree(IterableRealInterval<T> interval) Construct a KDTree from the elements of the givenIterableRealInterval.KDTree(KDTreeData<T> data) -
Method Summary
Modifier and TypeMethodDescriptionCreate a re-usableKDTreeNodeproxy linked to this tree.cursor()Returns aRealCursorthat iterates with optimal speed without calculating the location at each iteration step.getRoot()Deprecated.getType()Get an instance ofT.impl()Access to pure coordinate kD Tree implementation.Returns the iteration order of thisIterableRealInterval.iterator()(package private) KDTreeNode<T> left(KDTreeNode<T> parent) Returns aRealLocalizableIteratorthat calculates its location at each iteration step.intGets the space's number of dimensions.private static <A> Iterable<RealLocalizable> positionsIterable(IterableRealInterval<A> sourceInterval) doublerealMax(int d) Get the maximum in dimension d.doublerealMin(int d) Get the minimum in dimension d.(package private) KDTreeNode<T> right(KDTreeNode<T> parent) longsize()Returns the number of elements in thisFunction.toString()private StringtoString(int node, String indent, KDTreeNode<T> ref) treeData()Access to underlying data for serialization.private static intverifySize(List<?> values, List<?> positions) private static intverifySize(IterableRealInterval<?> interval) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IterableRealInterval
firstElement, localizingSpliterator, parallelStream, spliterator, streamMethods inherited from interface RealInterval
maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint, realMax, realMax, realMin, realMin
-
Field Details
-
treeData
-
impl
-
MAX_ARRAY_SIZE
private static final int MAX_ARRAY_SIZE- See Also:
-
-
Constructor Details
-
KDTree
Construct a KDTree from the elements in the given list.Note that the constructor can be called with the same list for both
values == positionsifT extends RealLocalizable.- Parameters:
values- a list of valuespositions- a list of positions corresponding to the values
-
KDTree
Construct a KDTree from the elements of the givenIterableRealInterval.- Parameters:
interval- elements in the tree are obtained by iterating this
-
KDTree
-
KDTree
-
-
Method Details
-
treeData
Access to underlying data for serialization. -
impl
Access to pure coordinate kD Tree implementation. -
verifySize
-
verifySize
-
positionsIterable
private static <A> Iterable<RealLocalizable> positionsIterable(IterableRealInterval<A> sourceInterval) -
getRoot
Deprecated.KDTreeNodeis now a re-usable proxy (likeNativeType). To work with existing code,KDTreeNode.left(),KDTreeNode.right(),getRoot()etc create new objects in each call, instead of re-using existing proxies. Code using that should be rewritten to reuse proxies, if possible.Get the root node.- Returns:
- the root node.
-
getType
Description copied from interface:IterableRealIntervalGet an instance ofT.It should not be assumed that the returned
Tinstance is an independent copy. In particular, repeated calls togetType()may return the same instance.The default implementation returns
IterableRealInterval.firstElement(). Derived classes may choose different implementations for improved performance. -
numDimensions
public int numDimensions()Description copied from interface:EuclideanSpaceGets the space's number of dimensions.- Specified by:
numDimensionsin interfaceEuclideanSpace
-
realMin
public double realMin(int d) Description copied from interface:RealIntervalGet the minimum in dimension d.- Specified by:
realMinin interfaceRealInterval- Parameters:
d- dimension- Returns:
- minimum in dimension d.
-
realMax
public double realMax(int d) Description copied from interface:RealIntervalGet the maximum in dimension d.- Specified by:
realMaxin interfaceRealInterval- Parameters:
d- dimension- Returns:
- maximum in dimension d.
-
cursor
Description copied from interface:IterableRealIntervalReturns a
RealCursorthat iterates with optimal speed without calculating the location at each iteration step. Localization is performed on demand.Use this where localization is required rarely/ not for each iteration.
- Specified by:
cursorin interfaceIterableRealInterval<T>- Returns:
- fast iterating iterator
-
localizingCursor
Description copied from interface:IterableRealIntervalReturns a
RealLocalizableIteratorthat calculates its location at each iteration step. That is, localization is performed with optimal speed.Use this where localization is required often/ for each iteration.
- Specified by:
localizingCursorin interfaceIterableRealInterval<T>- Returns:
- fast localizing iterator
-
iterator
-
size
public long size()Description copied from interface:IterableRealIntervalReturns the number of elements in this
Function.- Specified by:
sizein interfaceIterableRealInterval<T>- Returns:
- number of elements
-
iterationOrder
Description copied from interface:IterableRealIntervalReturns the iteration order of thisIterableRealInterval. If the returned object equals (Object.equals(Object)) the iteration order of anotherIterableRealIntervalf then they can be copied by synchronous iteration. That is, having anIteratoron this and anotherIteratoron f, moving both in synchrony will point both of them to corresponding locations in their source domain. In other words, this and f have the same iteration order and means and the same number of elements.- Specified by:
iterationOrderin interfaceIterableRealInterval<T>- Returns:
- the iteration order of this
IterableRealInterval. - See Also:
-
toString
-
toString
-
createNode
Create a re-usableKDTreeNodeproxy linked to this tree.KDTreeNode.setNodeIndex(int)can be used to point the proxy to a particular node in the tree. -
left
-
right
-
KDTreeNodeis now a re-usable proxy (likeNativeType).