Package sim.util
Class MutableInt3D
java.lang.Object
sim.util.NumberND
sim.util.MutableNumberND
sim.util.MutableInt3D
- All Implemented Interfaces:
Serializable,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:
-
Field Summary
FieldsFields inherited from class sim.util.NumberND
TYPE_DOUBLE_2D, TYPE_DOUBLE_3D, TYPE_INT_2D, TYPE_INT_3D, TYPE_MUTABLE_DOUBLE_2D, TYPE_MUTABLE_DOUBLE_3D, TYPE_MUTABLE_INT_2D, TYPE_MUTABLE_INT_3D -
Constructor Summary
ConstructorsConstructorDescriptionMutableInt3D(int x, int y, int z) Explicitly assumes the z value is set to 0MutableInt3D(Int2D p, int z) MutableInt3D(MutableInt2D p, int z) -
Method Summary
Modifier and TypeMethodDescriptionclone()doubledistance(double x, double y, double z) Returns the distance FROM this Int3D TO the specified pointdoubleReturns the distance FROM this Int3D TO the specified point.doubleReturns the distance FROM this Int3D TO the specified point.doubleReturns the distance FROM this Int3D TO the specified point.doubledistanceSq(double x, double y, double z) Returns the squared distance FROM this Int3D TO the specified pointdoubleReturns the squared distance FROM this Int3D TO the specified point.doubledistanceSq(Int3D p) Returns the squared distance FROM this Int3D TO the specified point.doubleReturns the squared distance FROM this Int3D TO the specified point.booleanReturns whether this NumberND is equivalent to some other NumberND.doublegetVal(int val) Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)final intgetX()final intgetY()final intgetZ()inthashCode()Provides a hashcode for this NumberND.longmanhattanDistance(int x, int y, int z) Returns the manhattan distance FROM this Int3D TO the specified point.longReturns the manhattan distance FROM this Int3D TO the specified point.longReturns the manhattan distance FROM this Int3D TO the specified point.booleanmutable()Returns whether this NumberND is mutable.intReturns the number of dimensions of this NumberND (normally 2 or 3)voidsetLocation(int x, int y, int z) Deprecated.use setTovoidsetLocation(Int3D p) Deprecated.use setTovoidDeprecated.use setTovoidsetTo(int x, int y, int z) voidvoidvoidsetVal(int val, double to) final voidsetX(int val) final voidsetY(int val) final voidsetZ(int val) double[]byte[]toBytes()Flattens out the NumberND to an array of bytes, including the NumberND subtype.Returns this NumberND in mathematical coordinates as a formatted String.toString()Returns this NumberND as a nicely formatted String.Methods inherited from class sim.util.MutableNumberND
isMutableMethods inherited from class sim.util.NumberND
doubleFromBytes, doubleToBytes, fromBytes, getDistanceSq, getOffsets, intFromBytes, intToBytes, main
-
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
Explicitly assumes the z value is set to 0 -
MutableInt3D
-
MutableInt3D
-
MutableInt3D
-
MutableInt3D
-
-
Method Details
-
mutable
public boolean mutable()Description copied from class:NumberNDReturns whether this NumberND is mutable. This is equivalent to asking (instanceof val MutableNumberND) -
numDimensions
public int numDimensions()Description copied from class:NumberNDReturns the number of dimensions of this NumberND (normally 2 or 3)- Specified by:
numDimensionsin classNumberND
-
getVal
public double getVal(int val) Description copied from class:NumberNDReturns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2) -
setVal
public void setVal(int val, double to) - Specified by:
setValin classMutableNumberND
-
toBytes
public byte[] toBytes()Description copied from class:NumberNDFlattens out the NumberND to an array of bytes, including the NumberND subtype. -
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
-
setTo
-
setLocation
public void setLocation(int x, int y, int z) Deprecated.use setTo -
setLocation
Deprecated.use setTo -
setLocation
Deprecated.use setTo -
toString
Description copied from class:NumberNDReturns this NumberND as a nicely formatted String. -
toCoordinates
Description copied from class:NumberNDReturns this NumberND in mathematical coordinates as a formatted String.- Specified by:
toCoordinatesin classNumberND
-
toArrayAsDouble
public double[] toArrayAsDouble()- Specified by:
toArrayAsDoublein classNumberND
-
clone
-
hashCode
public int hashCode()Description copied from class:NumberNDProvides a hashcode for this NumberND. -
equals
Description copied from class:NumberNDReturns whether this NumberND is equivalent to some other NumberND. -
distance
public double distance(double x, double y, double z) Returns the distance FROM this Int3D TO the specified point -
distance
Returns the distance FROM this Int3D TO the specified point. -
distance
Returns the distance FROM this Int3D TO the specified point. -
distance
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
Returns the squared distance FROM this Int3D TO the specified point. -
distanceSq
Returns the squared distance FROM this Int3D TO the specified point. -
distanceSq
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
Returns the manhattan distance FROM this Int3D TO the specified point. -
manhattanDistance
Returns the manhattan distance FROM this Int3D TO the specified point.
-