Class VNQuery<T>

java.lang.Object
repast.simphony.query.space.grid.AbstractGridQuery<T>
repast.simphony.query.space.grid.VNQuery<T>
All Implemented Interfaces:
Query<T>

public class VNQuery<T> extends AbstractGridQuery<T>
Queries a grid for the Von Neumann neighborhood of a specific point or object.
Author:
Nick Collier
  • Field Summary

    Fields inherited from class repast.simphony.query.space.grid.AbstractGridQuery

    dims, emptyList, extent, grid, maxs, mins, point
  • Constructor Summary

    Constructors
    Constructor
    Description
    VNQuery(Grid<T> grid, T source, int... extent)
    Creates a Von Neumann query on the specified grid using the specified object as the source where the neighborhood is specified by the extent.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets an iterable over all the objects that make up the Von Neumann neighborhood of the source object.
    query(Iterable<T> iter)
    Gets an iterable over all the objects that make up the Von Neumann neighborhood of the source object and are in the specified iterable.

    Methods inherited from class repast.simphony.query.space.grid.AbstractGridQuery

    reset

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • VNQuery

      public VNQuery(Grid<T> grid, T source, int... extent)
      Creates a Von Neumann query on the specified grid using the specified object as the source where the neighborhood is specified by the extent. The extent defines the dimensions of the neighborhood in the x, y, and optionaly z dimensions. If the extent args are missing, they default to one.

      This object can be reused by resetting the source and extents using the reset method. The queries will return an empty iterable if the source object does not have a grid location.

      Parameters:
      grid -
      source -
      extent -
  • Method Details

    • query

      public Iterable<T> query()
      Gets an iterable over all the objects that make up the Von Neumann neighborhood of the source object. The source object and neighborhood extent are specified in the constructor or the reset method. The order of the returned objects is left to right, up to down, and then optionally back to front.. For example, a 2d neighborhood centered at 2,2 with an extent of 1,1 will return the objects at (1,2), (3,2), (2, 1), (2,3).

      This will return an empty iterable if the source object does not have a grid location.

      Returns:
      an iterable over all the objects that make up the Moore neighborhood of the source object.
    • query

      public Iterable<T> query(Iterable<T> iter)
      Gets an iterable over all the objects that make up the Von Neumann neighborhood of the source object and are in the specified iterable. The source object and neighborhood extent are specified in the constructor or the reset method. The order of the returned objects is left to right, up to down, and then optionally back to front. For example, a 2d neighborhood centered at 2,2 with an extent of 1,1 will return the objects at (1,2), (3,2), (2, 1), (2,3).

      This will return an empty iterable if the source object does not have a grid location.

      Returns:
      an iterable over all the objects that make up the Moore neighborhood of the source object and are in the spefied iterable.