Package sim.util

Class MutableInt3D

All Implemented Interfaces:
Serializable, Cloneable

public final class MutableInt3D extends MutableNumberND
MutableInt3D stores three values (x, y, and z) and is hash-equivalent to Int3D; except MutableInt3D's values can be modified and Int3D's values cannot. It is used internally in SparseGrid3D and Continuous3D to do neighborhood lookups without having to create an Int3D every time (which causes lots of garbage collection).

You use MutableInt3D as a STORED hash key at your peril: it has the same misfeature as Point, and you should read the warning in Int3D. However, you can look up Int3D-keyed objects in a hash table by passing in a MutableInt3D instead.

See Also:
  • Field Details

    • x

      public int x
    • y

      public int y
    • z

      public int z
  • Constructor Details

    • MutableInt3D

      public MutableInt3D()
    • MutableInt3D

      public MutableInt3D(int x, int y, int z)
    • MutableInt3D

      public MutableInt3D(Int2D p)
      Explicitly assumes the z value is set to 0
    • MutableInt3D

      public MutableInt3D(Int2D p, int z)
    • MutableInt3D

      public MutableInt3D(Int3D p)
    • MutableInt3D

      public MutableInt3D(MutableInt2D p)
    • MutableInt3D

      public MutableInt3D(MutableInt2D p, int z)
  • Method Details

    • mutable

      public boolean mutable()
      Description copied from class: NumberND
      Returns whether this NumberND is mutable. This is equivalent to asking (instanceof val MutableNumberND)
      Overrides:
      mutable in class NumberND
    • numDimensions

      public int numDimensions()
      Description copied from class: NumberND
      Returns the number of dimensions of this NumberND (normally 2 or 3)
      Specified by:
      numDimensions in class NumberND
    • getVal

      public double getVal(int val)
      Description copied from class: NumberND
      Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)
      Specified by:
      getVal in class NumberND
    • setVal

      public void setVal(int val, double to)
      Specified by:
      setVal in class MutableNumberND
    • toBytes

      public byte[] toBytes()
      Description copied from class: NumberND
      Flattens out the NumberND to an array of bytes, including the NumberND subtype.
      Specified by:
      toBytes in class NumberND
    • getX

      public final int getX()
    • getY

      public final int getY()
    • getZ

      public final int getZ()
    • setX

      public final void setX(int val)
    • setY

      public final void setY(int val)
    • setZ

      public final void setZ(int val)
    • setTo

      public void setTo(int x, int y, int z)
    • setTo

      public void setTo(Int3D p)
    • setTo

      public void setTo(MutableInt3D p)
    • setLocation

      public void setLocation(int x, int y, int z)
      Deprecated.
      use setTo
    • setLocation

      public void setLocation(Int3D p)
      Deprecated.
      use setTo
    • setLocation

      public void setLocation(MutableInt3D p)
      Deprecated.
      use setTo
    • toString

      public String toString()
      Description copied from class: NumberND
      Returns this NumberND as a nicely formatted String.
      Specified by:
      toString in class NumberND
    • toCoordinates

      public String toCoordinates()
      Description copied from class: NumberND
      Returns this NumberND in mathematical coordinates as a formatted String.
      Specified by:
      toCoordinates in class NumberND
    • toArrayAsDouble

      public double[] toArrayAsDouble()
      Specified by:
      toArrayAsDouble in class NumberND
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Description copied from class: NumberND
      Provides a hashcode for this NumberND.
      Specified by:
      hashCode in class NumberND
    • equals

      public boolean equals(Object obj)
      Description copied from class: NumberND
      Returns whether this NumberND is equivalent to some other NumberND.
      Specified by:
      equals in class NumberND
    • distance

      public double distance(double x, double y, double z)
      Returns the distance FROM this Int3D TO the specified point
    • distance

      public double distance(Double3D p)
      Returns the distance FROM this Int3D TO the specified point.
    • distance

      public double distance(MutableInt3D p)
      Returns the distance FROM this Int3D TO the specified point.
    • distance

      public double distance(Int3D p)
      Returns the distance FROM this Int3D TO the specified point.
    • distanceSq

      public double distanceSq(double x, double y, double z)
      Returns the squared distance FROM this Int3D TO the specified point
    • distanceSq

      public double distanceSq(Double3D p)
      Returns the squared distance FROM this Int3D TO the specified point.
    • distanceSq

      public double distanceSq(MutableInt3D p)
      Returns the squared distance FROM this Int3D TO the specified point.
    • distanceSq

      public double distanceSq(Int3D p)
      Returns the squared distance FROM this Int3D TO the specified point.
    • manhattanDistance

      public long manhattanDistance(int x, int y, int z)
      Returns the manhattan distance FROM this Int3D TO the specified point.
    • manhattanDistance

      public long manhattanDistance(MutableInt3D p)
      Returns the manhattan distance FROM this Int3D TO the specified point.
    • manhattanDistance

      public long manhattanDistance(Int3D p)
      Returns the manhattan distance FROM this Int3D TO the specified point.