Class Grid2Dint

  • All Implemented Interfaces:
    Grid2D, java.io.Serializable

    public class Grid2Dint
    extends java.lang.Object
    implements Grid2D, java.io.Serializable
    a 2D Grid of ints
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int length  
      boolean wrapX  
      boolean wrapY  
      int xDim  
      int yDim  
    • Constructor Summary

      Constructors 
      Constructor Description
      Grid2Dint​(int xDim, int yDim)
      creates a new Grid2Dint of dimensions xDim by yDim without wraparound
      Grid2Dint​(int xDim, int yDim, boolean wrapX, boolean wrapY)
      creates a new Grid2Dint of dimensions xDim by yDim with optional wraparound
    • Method Summary

      Modifier and Type Method Description
      void Add​(int i, int val)
      adds to the current field value at the specified index
      void Add​(int x, int y, int val)
      adds to the current field value at the specified coordinates
      void AddAll​(int val)
      adds specified value to all entries of the curr field
      void BoundAll​(int min, int max)
      Bounds all values in the current field between min and max
      int Get​(int i)
      gets the current field value at the specified index
      int Get​(int x, int y)
      gets the current field value at the specified coordinates
      int GetAvg()
      gets the average value of all squares in the current field
      int[] GetField()
      returns the complete field as an array
      int GetMax()
      returns the max value in the grid
      int GetMin()
      returns the min value in the grid
      boolean IsWrapX()  
      boolean IsWrapY()  
      int Length()  
      void MulAll​(double val)
      adds specified value to all entries of the curr field
      void Scale​(int i, double val)
      multiplies the current field value at the specified index
      void Scale​(int x, int y, double val)
      multiplies the current field value at the specified coordinates
      void Set​(int i, int val)
      sets the current field value at the specified index
      void Set​(int x, int y, int val)
      sets the current field value at the specified coordinates
      void SetAll​(int val)
      sets all squares in current the field to the specified value
      void SetAll​(int[] vals)
      sets all squares in the field to the specified value
      int Xdim()  
      int Ydim()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • xDim

        public final int xDim
      • yDim

        public final int yDim
      • length

        public final int length
      • wrapX

        public boolean wrapX
      • wrapY

        public boolean wrapY
    • Constructor Detail

      • Grid2Dint

        public Grid2Dint​(int xDim,
                         int yDim)
        creates a new Grid2Dint of dimensions xDim by yDim without wraparound
      • Grid2Dint

        public Grid2Dint​(int xDim,
                         int yDim,
                         boolean wrapX,
                         boolean wrapY)
        creates a new Grid2Dint of dimensions xDim by yDim with optional wraparound
    • Method Detail

      • Get

        public int Get​(int i)
        gets the current field value at the specified index
      • GetField

        public int[] GetField()
        returns the complete field as an array
      • Get

        public int Get​(int x,
                       int y)
        gets the current field value at the specified coordinates
      • Set

        public void Set​(int i,
                        int val)
        sets the current field value at the specified index
      • Set

        public void Set​(int x,
                        int y,
                        int val)
        sets the current field value at the specified coordinates
      • Add

        public void Add​(int x,
                        int y,
                        int val)
        adds to the current field value at the specified coordinates
      • Scale

        public void Scale​(int x,
                          int y,
                          double val)
        multiplies the current field value at the specified coordinates
      • Scale

        public void Scale​(int i,
                          double val)
        multiplies the current field value at the specified index
      • Add

        public void Add​(int i,
                        int val)
        adds to the current field value at the specified index
      • BoundAll

        public void BoundAll​(int min,
                             int max)
        Bounds all values in the current field between min and max
      • SetAll

        public void SetAll​(int val)
        sets all squares in current the field to the specified value
      • AddAll

        public void AddAll​(int val)
        adds specified value to all entries of the curr field
      • MulAll

        public void MulAll​(double val)
        adds specified value to all entries of the curr field
      • SetAll

        public void SetAll​(int[] vals)
        sets all squares in the field to the specified value
      • GetAvg

        public int GetAvg()
        gets the average value of all squares in the current field
      • GetMax

        public int GetMax()
        returns the max value in the grid
      • GetMin

        public int GetMin()
        returns the min value in the grid
      • Xdim

        public int Xdim()
        Specified by:
        Xdim in interface Grid2D
      • Ydim

        public int Ydim()
        Specified by:
        Ydim in interface Grid2D
      • Length

        public int Length()
        Specified by:
        Length in interface Grid2D
      • IsWrapX

        public boolean IsWrapX()
        Specified by:
        IsWrapX in interface Grid2D
      • IsWrapY

        public boolean IsWrapY()
        Specified by:
        IsWrapY in interface Grid2D