Class WithinDistance<T>

  • All Implemented Interfaces:
    Query<T>
    Direct Known Subclasses:
    ContinuousWithin, GridWithin

    public abstract class WithinDistance<T>
    extends Object
    implements Query<T>
    Base class for queries whose results contains all the objects within some distance of a specified object.
    Version:
    $Revision$ $Date$
    Author:
    Nick Collier
    • Field Detail

      • EMPTY

        public static final List EMPTY
      • obj

        protected T obj
      • distanceSq

        protected double distanceSq
      • distance

        protected double distance
    • Constructor Detail

      • WithinDistance

        protected WithinDistance​(Context<T> context,
                                 double distance,
                                 T obj)
        Creates a WithinDistance query whose results will be all the objects in all the projections of a particular type in the context within some distance of the specified object. Subclasses will determine the projection type.
        Parameters:
        context -
        distance -
        obj -
    • Method Detail

      • query

        public Iterable<T> query()
        Returns the result of the query.
        Specified by:
        query in interface Query<T>
        Returns:
        an iterable over the objects that are the result of the query.
      • createIterable

        protected abstract Iterable<T> createIterable​(Context<T> context)
        Creates an iterable over all the relevant objects in the context.
        Parameters:
        context -
        Returns:
        an iterable over all the relevant objects in the context.
      • createIterable

        protected abstract Iterable<T> createIterable()
        Creates an iterable over all the relevant objects in a space. The actual space will depend on subclass implementations.
        Returns:
        an iterable over all the relevant objects in a space. The actual space will depend on subclass implementations.
      • query

        public Iterable<T> query​(Iterable<T> set)
        Returns an iterable over the objects that are the result of the query and are in the passed in iterable. This allows queries to be chained together where the result of one query is passed into another.
        Specified by:
        query in interface Query<T>
        Parameters:
        set -
        Returns:
        an iterable over the objects that are the result of the query and are in the passed in iterable.