Class MooreContains<T>


  • public class MooreContains<T>
    extends Object
    Determines whether or not a particular target is in the Moore neighborhood of a particular source. This works with 1D, 2D and 3D grids only.
    Version:
    $Revision$ $Date$
    Author:
    Nick Collier
    • Constructor Detail

      • MooreContains

        public MooreContains​(Grid<T> grid)
        Creates a MooreContains for the specified grid.
        Parameters:
        grid -
    • Method Detail

      • isNeighbor

        public boolean isNeighbor​(T source,
                                  T target,
                                  int... extent)
        Checks if the specified target is within the Moore neighborhood of the specified source. The neighborhood is defined by the extent argument which contains the extent of the neighborhood in the relevant dimensions. For example, assuming a 2D grid, a source at 4, 4, and and extent of 2, 1, the neighborhood would be a rectangle whose upper left corner was at 2, 5 with a width of 4 and a height of 2. If the extent is not specified it is assumed to be 1 in all dimensions.
        Parameters:
        source - the source object of the neighborhood
        target - the object to test if it is in the neighborhood
        extent - defines the extents of the neighborhood. If this is not specified then the extent is assumed to be 1 in all dimensions.
        Returns:
        true if the target is in the moore neighborhood of the source.