sim.util
Class MutableInt2D

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

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

MutableInt2D is largely a class identical to java.awt.Point, except that it is hash-equivalent to Int2D. It is used internally in SparseGrid2D and Continuous2D to do neighborhood lookups without having to create an Int2D every time (which causes lots of garbage collection).

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

See Also:
Serialized Form

Field Summary
 int x
           
 int y
           
 
Constructor Summary
MutableInt2D()
           
MutableInt2D(Int2D p)
           
MutableInt2D(int x, int y)
           
MutableInt2D(java.awt.Point p)
           
 
Method Summary
 java.lang.Object clone()
           
 double distance(Double2D p)
          Returns the distance FROM this MutableInt2D TO the specified point.
 double distance(double x, double y)
          Returns the distance FROM this MutableInt2D TO the specified point
 double distance(Int2D p)
          Returns the distance FROM this MutableInt2D TO the specified point.
 double distance(MutableInt2D p)
          Returns the distance FROM this MutableInt2D TO the specified point.
 double distance(java.awt.geom.Point2D p)
          Returns the distance FROM this MutableInt2D TO the specified point.
 double distanceSq(Double2D p)
          Returns the squared distance FROM this MutableInt2D TO the specified point.
 double distanceSq(double x, double y)
          Returns the squared distance FROM this MutableInt2D TO the specified point
 double distanceSq(Int2D p)
          Returns the squared distance FROM this MutableInt2D TO the specified point.
 double distanceSq(MutableInt2D p)
          Returns the squared distance FROM this MutableInt2D TO the specified point.
 double distanceSq(java.awt.geom.Point2D p)
          Returns the squared distance FROM this MutableInt2D TO the specified point
 boolean equals(java.lang.Object obj)
           
 int getX()
           
 int getY()
           
 int hashCode()
           
 long manhattanDistance(Int2D p)
          Returns the manhattan distance FROM this MutableInt2D TO the specified point.
 long manhattanDistance(int x, int y)
          Returns the manhattan distance FROM this MutableInt2D TO the specified point.
 long manhattanDistance(MutableInt2D p)
          Returns the manhattan distance FROM this MutableInt2D TO the specified point.
 long manhattanDistance(java.awt.Point p)
          Returns the manhattan distance FROM this Int2D TO the specified point.
 void setLocation(Int2D p)
          Deprecated. use setTo
 void setLocation(int x, int y)
          Deprecated. use setTo
 void setLocation(MutableInt2D p)
          Deprecated. use setTo
 void setLocation(java.awt.Point p)
          Deprecated. use setTo
 void setTo(Int2D p)
           
 void setTo(int x, int y)
           
 void setTo(MutableInt2D p)
           
 void setTo(java.awt.Point p)
           
 void setX(int val)
           
 void setY(int val)
           
 java.lang.String toCoordinates()
           
 java.awt.Point toPoint()
           
 java.awt.geom.Point2D.Double toPoint2D()
           
 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
Constructor Detail

MutableInt2D

public MutableInt2D()

MutableInt2D

public MutableInt2D(java.awt.Point p)

MutableInt2D

public MutableInt2D(Int2D p)

MutableInt2D

public MutableInt2D(int x,
                    int y)
Method Detail

getX

public final int getX()

getY

public final int getY()

setX

public final void setX(int val)

setY

public final void setY(int val)

setTo

public void setTo(int x,
                  int y)

setTo

public void setTo(java.awt.Point p)

setTo

public void setTo(Int2D p)

setTo

public void setTo(MutableInt2D p)

setLocation

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


setLocation

public void setLocation(java.awt.Point p)
Deprecated. use setTo


setLocation

public void setLocation(Int2D p)
Deprecated. use setTo


setLocation

public void setLocation(MutableInt2D p)
Deprecated. use setTo


toPoint2D

public java.awt.geom.Point2D.Double toPoint2D()

toPoint

public java.awt.Point toPoint()

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 final int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

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

distance

public double distance(double x,
                       double y)
Returns the distance FROM this MutableInt2D TO the specified point


distance

public double distance(Double2D p)
Returns the distance FROM this MutableInt2D TO the specified point.


distance

public double distance(MutableInt2D p)
Returns the distance FROM this MutableInt2D TO the specified point.


distance

public double distance(Int2D p)
Returns the distance FROM this MutableInt2D TO the specified point.


distance

public double distance(java.awt.geom.Point2D p)
Returns the distance FROM this MutableInt2D TO the specified point.


distanceSq

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


distanceSq

public double distanceSq(Double2D p)
Returns the squared distance FROM this MutableInt2D TO the specified point.


distanceSq

public double distanceSq(java.awt.geom.Point2D p)
Returns the squared distance FROM this MutableInt2D TO the specified point


distanceSq

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


distanceSq

public double distanceSq(Int2D p)
Returns the squared distance FROM this MutableInt2D TO the specified point.


manhattanDistance

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


manhattanDistance

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


manhattanDistance

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


manhattanDistance

public long manhattanDistance(java.awt.Point p)
Returns the manhattan distance FROM this Int2D TO the specified point.