cz.cuni.amis.pogamut.base.utils.math
Class DistanceUtils

Package class diagram package DistanceUtils
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.utils.math.DistanceUtils

public class DistanceUtils
extends Object

DistanceUtils consists of usual routines for selecting "X" from some "collections of Xes" that are in some "distance" relation to the "target", e.g., "get nearest weapon from collection of available weapons to my position".

Note that you may always use custom metric via DistanceUtils.IGetDistance interface.

Note that you may always use some custom filters via DistanceUtils.IDistanceFilter interface.

Author:
Jimmy, ik

Nested Class Summary
static class DistanceUtils.AcceptAllDistanceFilter<T>
          Filter that accepts all "objects" (does not filter anything out).
static class DistanceUtils.FilterAdapter<T>
          Adapter that wraps IFilter making it into DistanceUtils.IDistanceFilter.
static class DistanceUtils.GetLocatedDistance2D<T extends ILocated>
          Simple implementation of DistanceUtils.IGetDistance that uses Location.getDistance2D(Location) method.
static class DistanceUtils.GetLocatedDistance3D<T extends ILocated>
          Simple implementation of DistanceUtils.IGetDistance that uses Location.getDistance(Location) method.
static interface DistanceUtils.IBetterRelation<T>
          Relation-ship estimator between two ILocated objects and their distance (or whatever required).
static interface DistanceUtils.IDistanceFilter<T>
          Filter that allows to check whether "object" is accepted with respect to "distanceToTarget" for given "target".
static interface DistanceUtils.IGetDistance<T>
          Distance estimator between object of types T and some Location target.
static class DistanceUtils.RangeDistanceFilter<T>
          Filter that accepts all "objects" that are within range of min/max distance (inclusive).
static class DistanceUtils.RelationCloser<T>
          Prefer "closer" objects to "target"
static class DistanceUtils.RelationFurther<T>
          Prefer "further" objects to "target"
static class DistanceUtils.VisibleFilter<T extends IViewable>
          Accepts only VISIBLE (IViewable.isVisible() == TRUE) objects.
 
Field Summary
static DistanceUtils.AcceptAllDistanceFilter acceptAllDistanceFilter
          See DistanceUtils.AcceptAllDistanceFilter.
static DistanceUtils.GetLocatedDistance2D<ILocated> getLocatedDistance2D
          See DistanceUtils.GetLocatedDistance2D.
static DistanceUtils.GetLocatedDistance3D<ILocated> getLocatedDistance3D
          See DistanceUtils.GetLocatedDistance3D.
static DistanceUtils.IDistanceFilter[] NO_FILTER
          Contains single filter, acceptAllDistanceFilter, i.e., this will ACCEPTS-ALL-ITEMS.
static DistanceUtils.RelationCloser relationCloser
           
static DistanceUtils.RelationFurther relationFurther
           
static DistanceUtils.VisibleFilter<IViewable> visibleFilter
          See DistanceUtils.VisibleFilter.
 
Constructor Summary
DistanceUtils()
           
 
Method Summary
static
<T extends ILocated>
List<T>
getDistanceSorted(Collection<T> locations, ILocated target)
          Returns "locations" sorted according to the distance to "target".
static
<T extends ILocated>
List<T>
getDistanceSorted(Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns "locations" accepted by all "filters" sorted according to the distance to "target".
static
<T> List<T>
getDistanceSorted(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance)
          Returns "locations" sorted according to the distance to "target".
static
<T> List<T>
getDistanceSorted(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IDistanceFilter... filters)
          Returns "locations" accepted by all "filters" sorted according to the distance to "target".
static
<T extends ILocated>
List<T>
getDistanceSorted(Collection<T> locations, ILocated target, double maxDistance)
          Returns "locations" sorted according to the distance to "target".
static
<T extends ILocated>
List<T>
getDistanceSortedFiltered(Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns "locations" sorted according to the distance to "target".
static
<T extends IViewable>
List<T>
getDistanceSortedVisible(Collection<T> locations, ILocated target)
          Returns visible "locations" sorted according to the distance to "target".
static
<T extends ILocated>
T
getFarthest(Collection<T> locations, ILocated target)
          Returns the farthest object from 'locations' to 'target'.
static
<T extends ILocated>
T
getFarthest(Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the farthest object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T> T
getFarthest(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance)
          Returns the farthest object to 'target'.
static
<T> T
getFarthest(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IDistanceFilter... filters)
          Returns the farthest object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getFarthest(Collection<T> locations, ILocated target, double maxDistance)
          Returns the farthest object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getFarthest2D(Collection<T> locations, ILocated target)
          Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target'.
static
<T extends ILocated>
T
getFarthest2D(Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getFarthest2D(Collection<T> locations, ILocated target, double maxDistance)
          Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getFarthestFiltered(Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the farthest object from 'locations' to 'target' that is accepted by 'filter'.
static
<T extends ILocated>
T
getFarthestFiltered2D(Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by 'filter'.
static
<T extends IViewable>
T
getFarthestVisible(Collection<T> locations, ILocated target)
          Returns the farthest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T extends IViewable>
T
getFarthestVisible2D(Collection<T> locations, ILocated target)
          Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T> T
getInBestRelation(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IBetterRelation betterRelation)
          Returns "in-best-distance-relation-to-'target'" object.
static
<T> T
getInBestRelation(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IBetterRelation betterRelation, DistanceUtils.IDistanceFilter... filters)
          Returns "in-best-distance-relation-to-'target'" object.
static
<T> T
getInNthBestRelation(int nthBest, Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IBetterRelation betterRelation)
          Returns "in-nth-best-distance-relation-to-'target'" object from 'locations'.
static
<T> T
getInNthBestRelation(int nthBest, Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IBetterRelation betterRelation, DistanceUtils.IDistanceFilter... filters)
          Returns "in-nth-best-distance-relation-to-'target'" object from 'location'.
static
<T extends ILocated>
T
getNearest(Collection<T> locations, ILocated target)
          Returns the nearest object from 'locations' to 'target'.
static
<T extends ILocated>
T
getNearest(Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the nearest object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T> T
getNearest(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance)
          Returns the nearest object from 'locations' to 'target'.
static
<T> T
getNearest(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IDistanceFilter... filters)
          Returns the nearest object from 'location' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getNearest(Collection<T> locations, ILocated target, double maxDistance)
          Returns the nearest object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getNearest2D(Collection<T> locations, ILocated target)
          Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target'.
static
<T extends ILocated>
T
getNearest2D(Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getNearest2D(Collection<T> locations, ILocated target, double maxDistance)
          Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getNearestFiltered(Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the nearest object from 'location' to 'target' that is accepted by 'filter'.
static
<T extends ILocated>
T
getNearestFiltered2D(Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the nearest (in 2D ~ [x,y]) object from 'location' to 'target' that is accepted by 'filter'.
static
<T extends IViewable>
T
getNearestVisible(Collection<T> locations, ILocated target)
          Returns the nearest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T extends IViewable>
T
getNearestVisible2D(Collection<T> locations, ILocated target)
          Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T extends ILocated>
T
getNthFarthest(int nthFarthest, Collection<T> locations, ILocated target)
          Returns the nth-farthest object from 'locations' to 'target'.
static
<T extends ILocated>
T
getNthFarthest(int nthFarthest, Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the nth-farthest object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T> T
getNthFarthest(int nthFarthest, Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance)
          Returns the n-th farthest object from 'locations' to 'target'.
static
<T> T
getNthFarthest(int nthFarthest, Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IDistanceFilter... filters)
          Returns the n-th farthest object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getNthFarthest(int nthFarthest, Collection<T> locations, ILocated target, double maxDistance)
          Returns the nth-farthest object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getNthFarthest2D(int nthFarthest, Collection<T> locations, ILocated target)
          Returns the nth-farthest object from 'locations' to 'target'.
static
<T extends ILocated>
T
getNthFarthest2D(int nthFarthest, Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getNthFarthest2D(int nthFarthest, Collection<T> locations, ILocated target, double maxDistance)
          Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getNthFarthestFiltered(int nthFarthest, Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the nth-farthest object from 'locations' to 'target' that is accepted by 'filter'.
static
<T extends ILocated>
T
getNthFarthestFiltered2D(int nthFarthest, Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by 'filter'.
static
<T extends IViewable>
T
getNthFarthestVisible(int nthFarthest, Collection<T> locations, ILocated target)
          Returns the nth-farthest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T extends IViewable>
T
getNthFarthestVisible2D(int nthFarthest, Collection<T> locations, ILocated target)
          Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T extends ILocated>
T
getNthNearest(int nthNearest, Collection<T> locations, ILocated target)
          Returns the nth-nearest object from 'locations' to 'target'.
static
<T extends ILocated>
T
getNthNearest(int nthNearest, Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the nearest object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T> T
getNthNearest(int nthNearest, Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance)
          Returns the n-th nearest object from 'locations' to 'target'.
static
<T> T
getNthNearest(int nthNearest, Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IDistanceFilter... filters)
          Returns the n-th nearest object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getNthNearest(int nthNearest, Collection<T> locations, ILocated target, double maxDistance)
          Returns the nth-nearest object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getNthNearest2D(int nthNearest, Collection<T> locations, ILocated target)
          Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target'.
static
<T extends ILocated>
T
getNthNearest2D(int nthNearest, Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.
static
<T extends ILocated>
T
getNthNearest2D(int nthNearest, Collection<T> locations, ILocated target, double maxDistance)
          Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.
static
<T extends ILocated>
T
getNthNearestFiltered(int nthNearest, Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the nth-nearest object from 'locations' to 'target' that is accepted by 'filter'.
static
<T extends ILocated>
T
getNthNearestFiltered2D(int nthNearest, Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by 'filter'.
static
<T extends IViewable>
T
getNthNearestVisible(int nthNearest, Collection<T> locations, ILocated target)
          Returns the nth-nearest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T extends IViewable>
T
getNthNearestVisible2D(int nthNearest, Collection<T> locations, ILocated target)
          Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).
static
<T extends ILocated>
T
getSecondNearest(Collection<T> locations, ILocated target)
          Deprecated. 
static
<T extends ILocated>
T
getSecondNearest(Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Deprecated. 
static
<T> T
getSecondNearest(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance)
          Deprecated. 
static
<T> T
getSecondNearest(Collection<T> locations, ILocated target, DistanceUtils.IGetDistance getDistance, DistanceUtils.IDistanceFilter... filters)
          Deprecated. 
static
<T extends ILocated>
T
getSecondNearest(Collection<T> locations, ILocated target, double maxDistance)
          Deprecated. 
static
<T extends ILocated>
T
getSecondNearest2D(Collection<T> locations, ILocated target)
          Deprecated. 
static
<T extends ILocated>
T
getSecondNearest2D(Collection<T> locations, ILocated target, DistanceUtils.IDistanceFilter... filters)
          Deprecated. 
static
<T extends ILocated>
T
getSecondNearest2D(Collection<T> locations, ILocated target, double maxDistance)
          Deprecated. 
static
<T extends ILocated>
T
getSecondNearest2DFiltered(Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter<T> filter)
          Deprecated. 
static
<T extends IViewable>
T
getSecondNearest2DVisible(Collection<T> locations, ILocated target)
          Deprecated. 
static
<T extends ILocated>
T
getSecondNearestFiltered(Collection<T> locations, ILocated target, cz.cuni.amis.utils.IFilter filter)
          Deprecated. 
static
<T extends IViewable>
T
getSecondNearestVisible(Collection<T> locations, ILocated target)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relationCloser

public static final DistanceUtils.RelationCloser relationCloser

relationFurther

public static final DistanceUtils.RelationFurther relationFurther

getLocatedDistance3D

public static final DistanceUtils.GetLocatedDistance3D<ILocated> getLocatedDistance3D
See DistanceUtils.GetLocatedDistance3D.


getLocatedDistance2D

public static final DistanceUtils.GetLocatedDistance2D<ILocated> getLocatedDistance2D
See DistanceUtils.GetLocatedDistance2D.


acceptAllDistanceFilter

public static final DistanceUtils.AcceptAllDistanceFilter acceptAllDistanceFilter
See DistanceUtils.AcceptAllDistanceFilter.


NO_FILTER

public static final DistanceUtils.IDistanceFilter[] NO_FILTER
Contains single filter, acceptAllDistanceFilter, i.e., this will ACCEPTS-ALL-ITEMS.


visibleFilter

public static final DistanceUtils.VisibleFilter<IViewable> visibleFilter
See DistanceUtils.VisibleFilter.

Constructor Detail

DistanceUtils

public DistanceUtils()
Method Detail

getInBestRelation

public static <T> T getInBestRelation(Collection<T> locations,
                                      ILocated target,
                                      DistanceUtils.IGetDistance getDistance,
                                      DistanceUtils.IBetterRelation betterRelation,
                                      DistanceUtils.IDistanceFilter... filters)
Returns "in-best-distance-relation-to-'target'" object.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

Relation checking is provided via IBetterRelation#isBetterRelation(Object, ILocated, double, double).

Only 'locations' that passes ALL 'filters' may get into the result. WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance - distance-computer between 'locations' and 'target'.
betterRelation - assessing
filters - if null or empty, is ignored
Returns:
nearest object from collection of objects

getInBestRelation

public static <T> T getInBestRelation(Collection<T> locations,
                                      ILocated target,
                                      DistanceUtils.IGetDistance getDistance,
                                      DistanceUtils.IBetterRelation betterRelation)
Returns "in-best-distance-relation-to-'target'" object.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

Relation checking is provided via IBetterRelation#isBetterRelation(Object, ILocated, double, double). WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
betterRelation -
Returns:
nearest object from collection of objects

getInNthBestRelation

public static <T> T getInNthBestRelation(int nthBest,
                                         Collection<T> locations,
                                         ILocated target,
                                         DistanceUtils.IGetDistance getDistance,
                                         DistanceUtils.IBetterRelation betterRelation,
                                         DistanceUtils.IDistanceFilter... filters)
Returns "in-nth-best-distance-relation-to-'target'" object from 'location'. This means is will not get the 1st best, 2nd best but n-th best, i.e., if we would sort all 'locations' according to 'betterRelation', this returns n-th element.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

Relation checking is provided via IBetterRelation#isBetterRelation(Object, ILocated, double, double).

Only 'locations' that passes ALL 'filters' may get into the result. WARNING: O(locations.size * N) ~ O(n^2) complexity!

Type Parameters:
T -
Parameters:
nthBest - if <= 0, returns the 1-BEST
locations - if locations.size() < 'nthBest', returns the "worst" from 'locations'
target -
getDistance - distance computer between 'locations' and 'target'.
filters - if insufficient (< nthBest) locations gets to the result, the "worst" is returned, or null in case of all locations are filtered out
Returns:
"in-nth-best-distance-relation-to-'target'" object from 'location'

getInNthBestRelation

public static <T> T getInNthBestRelation(int nthBest,
                                         Collection<T> locations,
                                         ILocated target,
                                         DistanceUtils.IGetDistance getDistance,
                                         DistanceUtils.IBetterRelation betterRelation)
Returns "in-nth-best-distance-relation-to-'target'" object from 'locations'. This means is will not get the 1st best, 2nd best but n-th best, i.e., if we would sort all 'locations' according to 'betterRelation', this returns n-th element.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

Relation checking is provided via IBetterRelation#isBetterRelation(Object, ILocated, double, double). WARNING: O(locations.size * N) ~ O(n^2) complexity!

Type Parameters:
T -
Parameters:
nthBest - if <= 0, returns the 1-BEST
locations - if locations.size() < 'nthBest', returns the "worst" from 'locations'
target -
getDistance - distance computer between 'locations' and 'target'.
Returns:
nth-nearest object from 'locations'

getNearest

public static <T> T getNearest(Collection<T> locations,
                               ILocated target,
                               DistanceUtils.IGetDistance getDistance,
                               DistanceUtils.IDistanceFilter... filters)
Returns the nearest object from 'location' to 'target' that is accepted by all 'filters'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
filters - filters to be used (that can filter out unsuitable results)
Returns:
nearest object from 'locations'

getNthNearest

public static <T> T getNthNearest(int nthNearest,
                                  Collection<T> locations,
                                  ILocated target,
                                  DistanceUtils.IGetDistance getDistance,
                                  DistanceUtils.IDistanceFilter... filters)
Returns the n-th nearest object from 'locations' to 'target' that is accepted by all 'filters'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
filters - filters to be used (that can filter out unsuitable results)
Returns:
nth-nearest object from 'locations'

getFarthest

public static <T> T getFarthest(Collection<T> locations,
                                ILocated target,
                                DistanceUtils.IGetDistance getDistance,
                                DistanceUtils.IDistanceFilter... filters)
Returns the farthest object from 'locations' to 'target' that is accepted by all 'filters'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
filters - filters to be used (that can filter out unsuitable results)
Returns:
nearest object from 'location'

getNthFarthest

public static <T> T getNthFarthest(int nthFarthest,
                                   Collection<T> locations,
                                   ILocated target,
                                   DistanceUtils.IGetDistance getDistance,
                                   DistanceUtils.IDistanceFilter... filters)
Returns the n-th farthest object from 'locations' to 'target' that is accepted by all 'filters'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
filters - filters to be used (that can filter out unsuitable results)
Returns:
nearest object from 'locations'

getNearest

public static <T> T getNearest(Collection<T> locations,
                               ILocated target,
                               DistanceUtils.IGetDistance getDistance)
Returns the nearest object from 'locations' to 'target'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
Returns:
nearest object from 'locations'

getNthNearest

public static <T> T getNthNearest(int nthNearest,
                                  Collection<T> locations,
                                  ILocated target,
                                  DistanceUtils.IGetDistance getDistance)
Returns the n-th nearest object from 'locations' to 'target'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
Returns:
nth-nearest object from 'locations'

getFarthest

public static <T> T getFarthest(Collection<T> locations,
                                ILocated target,
                                DistanceUtils.IGetDistance getDistance)
Returns the farthest object to 'target'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
Returns:
farthest object from 'locations'

getNthFarthest

public static <T> T getNthFarthest(int nthFarthest,
                                   Collection<T> locations,
                                   ILocated target,
                                   DistanceUtils.IGetDistance getDistance)
Returns the n-th farthest object from 'locations' to 'target'.

Distance is obtained via provided IGetDistance#getDistance(Object, Location).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
getDistance - distance computer between 'locations' and 'target'.
Returns:
nth-farthest object from 'locations'

getNearest

public static <T extends ILocated> T getNearest(Collection<T> locations,
                                                ILocated target,
                                                DistanceUtils.IDistanceFilter... filters)
Returns the nearest object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filters -
Returns:
nearest object from 'locations'

getNthNearest

public static <T extends ILocated> T getNthNearest(int nthNearest,
                                                   Collection<T> locations,
                                                   ILocated target,
                                                   DistanceUtils.IDistanceFilter... filters)
Returns the nearest object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
filters -
Returns:
nearest object from 'locations'

getFarthest

public static <T extends ILocated> T getFarthest(Collection<T> locations,
                                                 ILocated target,
                                                 DistanceUtils.IDistanceFilter... filters)
Returns the farthest object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filters -
Returns:
farthest object from 'locations'

getNthFarthest

public static <T extends ILocated> T getNthFarthest(int nthFarthest,
                                                    Collection<T> locations,
                                                    ILocated target,
                                                    DistanceUtils.IDistanceFilter... filters)
Returns the nth-farthest object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
filters -
Returns:
nth-farthest object from 'locations'

getNearest

public static <T extends ILocated> T getNearest(Collection<T> locations,
                                                ILocated target)
Returns the nearest object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from 'locations'

getNthNearest

public static <T extends ILocated> T getNthNearest(int nthNearest,
                                                   Collection<T> locations,
                                                   ILocated target)
Returns the nth-nearest object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
Returns:
nth-nearest object from 'locations'

getFarthest

public static <T extends ILocated> T getFarthest(Collection<T> locations,
                                                 ILocated target)
Returns the farthest object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
farthest object from 'locations'

getNthFarthest

public static <T extends ILocated> T getNthFarthest(int nthFarthest,
                                                    Collection<T> locations,
                                                    ILocated target)
Returns the nth-farthest object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
Returns:
nth-farthest object from 'locations'

getNearest

public static <T extends ILocated> T getNearest(Collection<T> locations,
                                                ILocated target,
                                                double maxDistance)
Returns the nearest object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
maxDistance -
Returns:
nearest object from 'locations' that is not further than 'maxDistance'

getNthNearest

public static <T extends ILocated> T getNthNearest(int nthNearest,
                                                   Collection<T> locations,
                                                   ILocated target,
                                                   double maxDistance)
Returns the nth-nearest object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
maxDistance -
Returns:
nth-nearest object from 'locations' that is not further than 'maxDistance'

getFarthest

public static <T extends ILocated> T getFarthest(Collection<T> locations,
                                                 ILocated target,
                                                 double maxDistance)
Returns the farthest object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
maxDistance -
Returns:
farthest object from 'locations' that is not further than 'maxDistance'

getNthFarthest

public static <T extends ILocated> T getNthFarthest(int nthFarthest,
                                                    Collection<T> locations,
                                                    ILocated target,
                                                    double maxDistance)
Returns the nth-farthest object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
maxDistance -
Returns:
nth-farthest object from 'locations' that is not further than 'maxDistance'

getNearestFiltered

public static <T extends ILocated> T getNearestFiltered(Collection<T> locations,
                                                        ILocated target,
                                                        cz.cuni.amis.utils.IFilter filter)
Returns the nearest object from 'location' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
nearest object from 'locations' accepted by 'filter'

getNthNearestFiltered

public static <T extends ILocated> T getNthNearestFiltered(int nthNearest,
                                                           Collection<T> locations,
                                                           ILocated target,
                                                           cz.cuni.amis.utils.IFilter filter)
Returns the nth-nearest object from 'locations' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
nth-nearest object from 'locations' accepted by 'filter'

getFarthestFiltered

public static <T extends ILocated> T getFarthestFiltered(Collection<T> locations,
                                                         ILocated target,
                                                         cz.cuni.amis.utils.IFilter filter)
Returns the farthest object from 'locations' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
farthest object from 'locations' accepted by 'filter'

getNthFarthestFiltered

public static <T extends ILocated> T getNthFarthestFiltered(int nthFarthest,
                                                            Collection<T> locations,
                                                            ILocated target,
                                                            cz.cuni.amis.utils.IFilter filter)
Returns the nth-farthest object from 'locations' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
nth-farthest object from 'locations' accepted by 'filter'

getNearestVisible

public static <T extends IViewable> T getNearestVisible(Collection<T> locations,
                                                        ILocated target)
Returns the nearest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nearest visible object from 'locations'

getNthNearestVisible

public static <T extends IViewable> T getNthNearestVisible(int nthNearest,
                                                           Collection<T> locations,
                                                           ILocated target)
Returns the nth-nearest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
ntNearest - if <= 0, returns the nearest
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nth-nearest visible object from 'locations'

getFarthestVisible

public static <T extends IViewable> T getFarthestVisible(Collection<T> locations,
                                                         ILocated target)
Returns the farthest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
farthest visible object from 'locations'

getNthFarthestVisible

public static <T extends IViewable> T getNthFarthestVisible(int nthFarthest,
                                                            Collection<T> locations,
                                                            ILocated target)
Returns the nth-farthest object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
ntFarthest - if <= 0, returns the farthest
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nth-farthest visible object from 'locations'

getDistanceSorted

public static <T> List<T> getDistanceSorted(Collection<T> locations,
                                            ILocated target,
                                            DistanceUtils.IGetDistance getDistance)
Returns "locations" sorted according to the distance to "target". Sorted from the nearest to the farthest.

Distance is provided by IGetDistance#getDistance(Object, Location).

WARNING: 2*O(n) + O(n*log n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance -
Returns:

getDistanceSorted

public static <T> List<T> getDistanceSorted(Collection<T> locations,
                                            ILocated target,
                                            DistanceUtils.IGetDistance getDistance,
                                            DistanceUtils.IDistanceFilter... filters)
Returns "locations" accepted by all "filters" sorted according to the distance to "target". Sorted from the nearest to the farthest.

Distance is provided by IGetDistance#getDistance(Object, Location).

WARNING: 2*O(n) + O(n*log n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
getDistance -
Returns:

getDistanceSorted

public static <T extends ILocated> List<T> getDistanceSorted(Collection<T> locations,
                                                             ILocated target,
                                                             DistanceUtils.IDistanceFilter... filters)
Returns "locations" accepted by all "filters" sorted according to the distance to "target". Sorted from the nearest to the farthest.

WARNING: 2*O(n) + O(n*log n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filters -
Returns:
nearest object from collection of objects

getDistanceSorted

public static <T extends ILocated> List<T> getDistanceSorted(Collection<T> locations,
                                                             ILocated target)
Returns "locations" sorted according to the distance to "target". Sorted from the nearest to the farthest.

WARNING: 2*O(n) + O(n*log n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getDistanceSorted

public static <T extends ILocated> List<T> getDistanceSorted(Collection<T> locations,
                                                             ILocated target,
                                                             double maxDistance)
Returns "locations" sorted according to the distance to "target". Sorted from the nearest to the farthest.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: 2*O(n) + O(n*log n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
maxDistance -
Returns:
nearest object from collection of objects that is not further than 'maxDistance'.

getDistanceSortedFiltered

public static <T extends ILocated> List<T> getDistanceSortedFiltered(Collection<T> locations,
                                                                     ILocated target,
                                                                     cz.cuni.amis.utils.IFilter filter)
Returns "locations" sorted according to the distance to "target". Sorted from the nearest to the farthest.

WARNING: 2*O(n) + O(n*log n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
nearest object from collection of objects

getDistanceSortedVisible

public static <T extends IViewable> List<T> getDistanceSortedVisible(Collection<T> locations,
                                                                     ILocated target)
Returns visible "locations" sorted according to the distance to "target". Sorted from the nearest to the farthest.

WARNING: 2*O(n) + O(n*log n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nearest visible object from collection of objects

getSecondNearest

@Deprecated
public static <T> T getSecondNearest(Collection<T> locations,
                                                ILocated target,
                                                DistanceUtils.IGetDistance getDistance)
Deprecated. 

Returns the second nearest object to 'target'.

Distance is provided by DistanceUtils.IGetDistance.getDistance(Object, ILocated).

WARNING: O(n) complexity!

DEPRECATED: use getNthNearest(int, Collection, ILocated, IGetDistance) instead!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getSecondNearest

@Deprecated
public static <T> T getSecondNearest(Collection<T> locations,
                                                ILocated target,
                                                DistanceUtils.IGetDistance getDistance,
                                                DistanceUtils.IDistanceFilter... filters)
Deprecated. 

Returns the second nearest object to 'target'.

WARNING: O(n) complexity!

DEPRECATED: use getNthNearest(int, Collection, ILocated, IGetDistance, IDistanceFilter...) instead

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest object from collection of objects

getSecondNearest

@Deprecated
public static <T extends ILocated> T getSecondNearest(Collection<T> locations,
                                                                 ILocated target,
                                                                 DistanceUtils.IDistanceFilter... filters)
Deprecated. 

Returns the second nearest object to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

DEPRECATED: use #getNthNearest(int, Collection, ILocated, IDistanceFilter...)) instead

Type Parameters:
T -
Parameters:
locations -
target -
filters -
Returns:
nearest object from collection of objects

getSecondNearest

@Deprecated
public static <T extends ILocated> T getSecondNearest(Collection<T> locations,
                                                                 ILocated target)
Deprecated. 

Returns the second nearest object to 'target'.

WARNING: O(n) complexity!

DEPRECATED: use getNthNearest(int, Collection, ILocated) instead

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
second nearest object from collection of objects

getSecondNearest

@Deprecated
public static <T extends ILocated> T getSecondNearest(Collection<T> locations,
                                                                 ILocated target,
                                                                 double maxDistance)
Deprecated. 

Returns the second nearest object to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

DEPRECATED: use getNthNearest(int, Collection, ILocated, double) instead

Type Parameters:
T -
Parameters:
locations -
target -
maxDistance -
Returns:
second nearest object from collection of objects that is not further than 'maxDistance'.

getSecondNearestFiltered

@Deprecated
public static <T extends ILocated> T getSecondNearestFiltered(Collection<T> locations,
                                                                         ILocated target,
                                                                         cz.cuni.amis.utils.IFilter filter)
Deprecated. 

Returns the second nearest object to 'target' that is accepted by filter.

WARNING: O(n) complexity!

DEPRECATED: use getNthNearestFiltered(int, Collection, ILocated, IFilter) instead

Type Parameters:
T -
Parameters:
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
second nearest object from collection of objects

getSecondNearestVisible

@Deprecated
public static <T extends IViewable> T getSecondNearestVisible(Collection<T> locations,
                                                                         ILocated target)
Deprecated. 

Returns the second nearest object to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

DEPRECATED: use {@link #getNthNearestVisible(int, Collection, ILocated)

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
second nearest visible object from collection of objects

getNearest2D

public static <T extends ILocated> T getNearest2D(Collection<T> locations,
                                                  ILocated target,
                                                  DistanceUtils.IDistanceFilter... filters)
Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filters -
Returns:
nearest (in 2D ~ [x,y]) object from 'locations'

getNthNearest2D

public static <T extends ILocated> T getNthNearest2D(int nthNearest,
                                                     Collection<T> locations,
                                                     ILocated target,
                                                     DistanceUtils.IDistanceFilter... filters)
Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
filters -
Returns:
nearest (in 2D ~ [x,y]) object from 'locations'

getFarthest2D

public static <T extends ILocated> T getFarthest2D(Collection<T> locations,
                                                   ILocated target,
                                                   DistanceUtils.IDistanceFilter... filters)
Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filters -
Returns:
farthest (in 2D ~ [x,y]) object from 'locations'

getNthFarthest2D

public static <T extends ILocated> T getNthFarthest2D(int nthFarthest,
                                                      Collection<T> locations,
                                                      ILocated target,
                                                      DistanceUtils.IDistanceFilter... filters)
Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
filters -
Returns:
nth-farthest (in 2D ~ [x,y]) object from 'locations'

getNearest2D

public static <T extends ILocated> T getNearest2D(Collection<T> locations,
                                                  ILocated target)
Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
nearest (in 2D ~ [x,y]) object from 'locations'

getNthNearest2D

public static <T extends ILocated> T getNthNearest2D(int nthNearest,
                                                     Collection<T> locations,
                                                     ILocated target)
Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
Returns:
nth-nearest (in 2D ~ [x,y]) object from 'locations'

getFarthest2D

public static <T extends ILocated> T getFarthest2D(Collection<T> locations,
                                                   ILocated target)
Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
farthest (in 2D ~ [x,y]) object from 'locations'

getNthFarthest2D

public static <T extends ILocated> T getNthFarthest2D(int nthFarthest,
                                                      Collection<T> locations,
                                                      ILocated target)
Returns the nth-farthest object from 'locations' to 'target'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
Returns:
nth-farthest (in 2D ~ [x,y]) object from 'locations'

getNearest2D

public static <T extends ILocated> T getNearest2D(Collection<T> locations,
                                                  ILocated target,
                                                  double maxDistance)
Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
maxDistance -
Returns:
nearest (in 2D ~ [x,y]) object from 'locations' that is not further than 'maxDistance'

getNthNearest2D

public static <T extends ILocated> T getNthNearest2D(int nthNearest,
                                                     Collection<T> locations,
                                                     ILocated target,
                                                     double maxDistance)
Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
maxDistance -
Returns:
nth-nearest (in 2D ~ [x,y]) object from 'locations' that is not further than 'maxDistance'

getFarthest2D

public static <T extends ILocated> T getFarthest2D(Collection<T> locations,
                                                   ILocated target,
                                                   double maxDistance)
Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
maxDistance -
Returns:
farthest (in 2D ~ [x,y]) object from 'locations' that is not further than 'maxDistance'

getNthFarthest2D

public static <T extends ILocated> T getNthFarthest2D(int nthFarthest,
                                                      Collection<T> locations,
                                                      ILocated target,
                                                      double maxDistance)
Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
maxDistance -
Returns:
nth-farthest (in 2D ~ [x,y]) object from 'locations' that is not further than 'maxDistance'

getNearestFiltered2D

public static <T extends ILocated> T getNearestFiltered2D(Collection<T> locations,
                                                          ILocated target,
                                                          cz.cuni.amis.utils.IFilter filter)
Returns the nearest (in 2D ~ [x,y]) object from 'location' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
nearest (in 2D ~ [x,y]) object from 'locations' accepted by 'filter'

getNthNearestFiltered2D

public static <T extends ILocated> T getNthNearestFiltered2D(int nthNearest,
                                                             Collection<T> locations,
                                                             ILocated target,
                                                             cz.cuni.amis.utils.IFilter filter)
Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthNearest - if <= 0, returns the nearest
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
nth-nearest (in 2D ~ [x,y]) object from 'locations' accepted by 'filter'

getFarthestFiltered2D

public static <T extends ILocated> T getFarthestFiltered2D(Collection<T> locations,
                                                           ILocated target,
                                                           cz.cuni.amis.utils.IFilter filter)
Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
farthest (in 2D ~ [x,y]) object from 'locations' accepted by 'filter'

getNthFarthestFiltered2D

public static <T extends ILocated> T getNthFarthestFiltered2D(int nthFarthest,
                                                              Collection<T> locations,
                                                              ILocated target,
                                                              cz.cuni.amis.utils.IFilter filter)
Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is accepted by 'filter'.

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
nthFarthest - if <= 0, returns the farthest
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
nth-farthest (in 2D ~ [x,y]) object from 'locations' accepted by 'filter'

getNearestVisible2D

public static <T extends IViewable> T getNearestVisible2D(Collection<T> locations,
                                                          ILocated target)
Returns the nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nearest (in 2D ~ [x,y]) visible object from 'locations'

getNthNearestVisible2D

public static <T extends IViewable> T getNthNearestVisible2D(int nthNearest,
                                                             Collection<T> locations,
                                                             ILocated target)
Returns the nth-nearest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
ntNearest - if <= 0, returns the nearest
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nth-nearest (in 2D ~ [x,y]) visible object from 'locations'

getFarthestVisible2D

public static <T extends IViewable> T getFarthestVisible2D(Collection<T> locations,
                                                           ILocated target)
Returns the farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
farthest (in 2D ~ [x,y]) visible object from 'locations'

getNthFarthestVisible2D

public static <T extends IViewable> T getNthFarthestVisible2D(int nthFarthest,
                                                              Collection<T> locations,
                                                              ILocated target)
Returns the nth-farthest (in 2D ~ [x,y]) object from 'locations' to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

Type Parameters:
T -
Parameters:
ntFarthest - if <= 0, returns the farthest
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
nth-farthest (in 2D ~ [x,y]) visible object from 'locations'

getSecondNearest2D

@Deprecated
public static <T extends ILocated> T getSecondNearest2D(Collection<T> locations,
                                                                   ILocated target,
                                                                   DistanceUtils.IDistanceFilter... filters)
Deprecated. 

Returns the second nearest (in 2D ~ [x,y]) object to 'target' that is accepted by all 'filters'.

WARNING: O(n) complexity!

DEPRECATED: use #getNthNearest2D(int, Collection, ILocated, filters) instead

Type Parameters:
T -
Parameters:
locations -
target -
filters -
Returns:
second nearest (in 2D ~ [x,y]) object from collection of objects

getSecondNearest2D

@Deprecated
public static <T extends ILocated> T getSecondNearest2D(Collection<T> locations,
                                                                   ILocated target)
Deprecated. 

Returns the second nearest (in 2D ~ [x,y]) object to 'target'.

WARNING: O(n) complexity!

DEPRECATAED: use getNthNearest2D(int, Collection, ILocated) instead

Type Parameters:
T -
Parameters:
locations -
target -
Returns:
second nearest (in 2D ~ [x,y]) object from collection of objects

getSecondNearest2D

@Deprecated
public static <T extends ILocated> T getSecondNearest2D(Collection<T> locations,
                                                                   ILocated target,
                                                                   double maxDistance)
Deprecated. 

Returns the second nearest (in 2D ~ [x,y]) object to 'target' that is not further than 'maxDistance'.

Using DistanceUtils.RangeDistanceFilter (minDistance = 0, maxDistance is provided).

WARNING: O(n) complexity!

DEPRECATED: use getNthNearest2D(int, Collection, ILocated, double) instead

Type Parameters:
T -
Parameters:
locations -
target -
maxDistance -
Returns:
second nearest (in 2D ~ [x,y]) object from collection of objects that is not further than 'maxDistance'.

getSecondNearest2DFiltered

@Deprecated
public static <T extends ILocated> T getSecondNearest2DFiltered(Collection<T> locations,
                                                                           ILocated target,
                                                                           cz.cuni.amis.utils.IFilter<T> filter)
Deprecated. 

Returns the second nearest (in 2D ~ [x,y]) object to 'target' that is accepted by filter.

WARNING: O(n) complexity!

DEPRECATED: use getNthNearestFiltered2D(int, Collection, ILocated, IFilter) instead

Type Parameters:
T -
Parameters:
locations -
target -
filter - if null behave as if ALL locations are accepted
Returns:
second nearest (in 2D ~ [x,y]) object from collection of objects

getSecondNearest2DVisible

@Deprecated
public static <T extends IViewable> T getSecondNearest2DVisible(Collection<T> locations,
                                                                           ILocated target)
Deprecated. 

Returns the second nearest (in 2D ~ [x,y]) object to 'target' that is visible (using DistanceUtils.VisibleFilter).

WARNING: O(n) complexity!

DEPRECATED: use getNthNearestVisible2D(int, Collection, ILocated) instead

Type Parameters:
T -
Parameters:
locations - must be objects implementing IViewable as well as ILocated (so Item or Player is usable)
target -
Returns:
second nearest (in 2D ~ [x,y]) visible object from collection of objects


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.