Class TwoDTree<T extends TwoDTree.Point>
java.lang.Object
rgu.transport.algorithms.collections.TwoDTree<T>
- Type Parameters:
T- the type of object
- All Implemented Interfaces:
NearestFinder<T>
A 2D tree used as a nearest finder with a compatible metric.
- Author:
- Lee A. Christie
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionFinds the nearest neighbour in the tree based on a Euclidean distance.static <T extends TwoDTree.Point>
TwoDTree<T> Creates a new 2D tree from the given set of points.static <T extends TwoDTree.Point>
TwoDTree<T> of(Set<T> points, ProgressListener progress) Creates a new 2D tree from the given set of points.static <T extends TwoDTree.Point>
TwoDTree<T> of(Set<T> points, ProgressListener progress, boolean subStageOnly) Creates a new 2D tree from the given set of points.withRatio(double ratio) Returns this 2D tree adapted to use a given stretch ratio (applied to the x-axis).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NearestFinder
cache, cache, concurrentCache, concurrentCache, nearest, nearest, nearestOrEmpty
-
Method Details
-
of
Creates a new 2D tree from the given set of points.- Type Parameters:
T- the element type- Parameters:
points- the points, not null- Returns:
- the tree
-
of
Creates a new 2D tree from the given set of points.- Type Parameters:
T- the element type- Parameters:
points- the points, not nullprogress- listener for the progress between 0.0 and 1.0, not null- Returns:
- the tree
-
of
public static <T extends TwoDTree.Point> TwoDTree<T> of(Set<T> points, ProgressListener progress, boolean subStageOnly) Creates a new 2D tree from the given set of points.- Type Parameters:
T- the element type- Parameters:
points- the points, not nullprogress- listener for the progress between 0.0 and 1.0, not nullsubStageOnly- if ture, will not call onNewStage or onCompletion on the progress listener- Returns:
- the tree
- Throws:
NoSuchElementException- if the collection is empty
-
nearest
Finds the nearest neighbour in the tree based on a Euclidean distance.- Specified by:
nearestin interfaceNearestFinder<T extends TwoDTree.Point>- Parameters:
target- the target, not null- Returns:
- the nearest neighbour
-
withRatio
Returns this 2D tree adapted to use a given stretch ratio (applied to the x-axis).- Parameters:
ratio- the ratio, finite, positive- Returns:
- this 2D tree with the given scale ratio
-