Interface NearestFinder<T>
- Type Parameters:
T- The type of elements
- All Known Implementing Classes:
ExhaustiveGeoLocationNearestFinderImpl, TwoDTree
public interface NearestFinder<T>
An object which can be used to find the nearest match within a predetermined
set of elements. A
NearestFinder
cannot refer to an empty set.- Author:
- Lee A. Christie
-
Method Summary
Modifier and TypeMethodDescriptiondefault NearestFinder<T> cache()Returns a cached version of the finder.default NearestFinder<T> Returns a cached version of the finder seeded with the specified starting map.default NearestFinder<T> Returns a thread-safe cached version of the finder.default NearestFinder<T> concurrentCache(Map<T, T> cache) Returns a thread-safe cached version of the finder seeded with the specified starting map.nearest(Collection<T> targets) Returns the element which is nearest to a target, for a collection of specified targets.nearest(Collection<T> targets, ProgressListener progress, boolean subStageOnly) Returns the element which is nearest to a target, for a collection of specified targets.Returns the element which is nearest to the specified target.nearestOrEmpty(T target) Returns an optional containing the element which is nearest to a target, for a collection of specified targets.
-
Method Details
-
nearest
Returns the element which is nearest to the specified target.- Parameters:
target- the target, not null- Returns:
- the nearest match
- Throws:
NoSuchElementException- if there is no nearest element
-
nearest
Returns the element which is nearest to a target, for a collection of specified targets.- Parameters:
targets- the targets, not null- Returns:
- a mapping of targets to the nearest matches
- Throws:
InterruptedException- if the thread is interrupted while matching the points to neighbours
-
nearestOrEmpty
Returns an optional containing the element which is nearest to a target, for a collection of specified targets.- Parameters:
target- the target, not null- Returns:
- a mapping of targets to the nearest matches or
Optional.emptyif there is no nearest element
-
nearest
default Map<T,T> nearest(Collection<T> targets, ProgressListener progress, boolean subStageOnly) throws InterruptedException Returns the element which is nearest to a target, for a collection of specified targets.- Parameters:
targets- the targets, 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:
- a mapping of targets to the nearest matches
- Throws:
InterruptedException- if the thread is interrupted while matching the points to neighbours
-
cache
Returns a cached version of the finder.- Returns:
- a cached version of the finder
-
cache
Returns a cached version of the finder seeded with the specified starting map. Elements in the starting map take priority over the backing finder.- Parameters:
cache- the cache to wrap, not null- Returns:
- a cached version of the finder
-
concurrentCache
Returns a thread-safe cached version of the finder.- Returns:
- a thread-safe cached version of the finder
-
concurrentCache
Returns a thread-safe cached version of the finder seeded with the specified starting map. Elements in the starting map take priority over the backing finder.- Parameters:
cache- the cache to wrap, not null- Returns:
- a thread-safe cached version of the finder
-