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
Fields 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
ConstructorDescriptionMutableInt3D
(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()
double
distance
(double x, double y, double z) Returns the distance FROM this Int3D TO the specified pointdouble
Returns the distance FROM this Int3D TO the specified point.double
Returns the distance FROM this Int3D TO the specified point.double
Returns the 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 pointdouble
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
Returns the squared distance FROM this Int3D TO the specified point.boolean
Returns whether this NumberND is equivalent to some other NumberND.double
getVal
(int val) Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)final int
getX()
final int
getY()
final int
getZ()
int
hashCode()
Provides a hashcode for this NumberND.long
manhattanDistance
(int x, int y, int z) Returns the manhattan distance FROM this Int3D TO the specified point.long
Returns the manhattan distance FROM this Int3D TO the specified point.long
Returns the manhattan distance FROM this Int3D TO the specified point.boolean
mutable()
Returns whether this NumberND is mutable.int
Returns the number of dimensions of this NumberND (normally 2 or 3)void
setLocation
(int x, int y, int z) Deprecated.use setTovoid
setLocation
(Int3D p) Deprecated.use setTovoid
Deprecated.use setTovoid
setTo
(int x, int y, int z) void
void
void
setVal
(int val, double to) final void
setX
(int val) final void
setY
(int val) final void
setZ
(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
isMutable
Methods 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:NumberND
Returns whether this NumberND is mutable. This is equivalent to asking (instanceof val MutableNumberND) -
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 classNumberND
-
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) -
setVal
public void setVal(int val, double to) - Specified by:
setVal
in classMutableNumberND
-
toBytes
public byte[] toBytes()Description copied from class:NumberND
Flattens 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:NumberND
Returns this NumberND as a nicely formatted String. -
toCoordinates
Description copied from class:NumberND
Returns this NumberND in mathematical coordinates as a formatted String.- Specified by:
toCoordinates
in classNumberND
-
toArrayAsDouble
public double[] toArrayAsDouble()- Specified by:
toArrayAsDouble
in classNumberND
-
clone
-
hashCode
public int hashCode()Description copied from class:NumberND
Provides a hashcode for this NumberND. -
equals
Description copied from class:NumberND
Returns 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.
-