sim.util
Class MutableInt3D

java.lang.Object
  extended by sim.util.MutableInt3D
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public final class MutableInt3D
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

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:
Serialized Form

Field Summary
 int x
           
 int y
           
 int z
           
 
Constructor Summary
MutableInt3D()
           
MutableInt3D(Int2D p)
          Explicitly assumes the z value is set to 0
MutableInt3D(Int2D p, int z)
           
MutableInt3D(Int3D p)
           
MutableInt3D(int x, int y, int z)
           
MutableInt3D(MutableInt2D p)
           
MutableInt3D(MutableInt2D p, int z)
           
 
Method Summary
 java.lang.Object clone()
           
 double distance(Double3D p)
          Returns the distance FROM this Int3D TO the specified point.
 double distance(double x, double y, double z)
          Returns the distance FROM this Int3D TO the specified point
 double distance(Int3D p)
          Returns the distance FROM this Int3D TO the specified point.
 double distance(MutableInt3D p)
          Returns the distance FROM this Int3D TO the specified point.
 double distanceSq(Double3D p)
          Returns the squared distance FROM this Int3D TO the specified point.
 double distanceSq(double x, double y, double z)
          Returns the squared distance FROM this Int3D TO the specified point
 double distanceSq(Int3D p)
          Returns the squared distance FROM this Int3D TO the specified point.
 double distanceSq(MutableInt3D p)
          Returns the squared distance FROM this Int3D TO the specified point.
 boolean equals(java.lang.Object obj)
           
 int getX()
           
 int getY()
           
 int getZ()
           
 int hashCode()
           
 long manhattanDistance(Int3D p)
          Returns the manhattan distance FROM this Int3D TO the specified point.
 long manhattanDistance(int x, int y, int z)
          Returns the manhattan distance FROM this Int3D TO the specified point.
 long manhattanDistance(MutableInt3D p)
          Returns the manhattan distance FROM this Int3D TO the specified point.
 void setLocation(Int3D p)
          Deprecated. use setTo
 void setLocation(int x, int y, int z)
          Deprecated. use setTo
 void setLocation(MutableInt3D p)
          Deprecated. use setTo
 void setTo(Int3D p)
           
 void setTo(int x, int y, int z)
           
 void setTo(MutableInt3D p)
           
 void setX(int val)
           
 void setY(int val)
           
 void setZ(int val)
           
 java.lang.String toCoordinates()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

z

public int z
Constructor Detail

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 Detail

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 java.lang.String toString()
Overrides:
toString in class java.lang.Object

toCoordinates

public java.lang.String toCoordinates()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

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.