sim.util
Class Int3D
java.lang.Object
sim.util.Int3D
- All Implemented Interfaces:
- java.io.Serializable
- public final class Int3D
- extends java.lang.Object
- implements java.io.Serializable
Int3D stores three values (x, y, and z) but it is immutable: once the x and y and z values are set, they cannot be changed (they're final). Unlike Double3D or Double2D or Int2D, Int3D has no mutable equivalent in the standard Java libraries. Like the others, Int3D is immutable primarily to prevent hash tables from breaking.
One day in the far future, Int3D should also be HIGHLY efficient; since it is immutable, it can be passed by value rather than by pointer by a smart compiler. Not today, though. But it's not bad.
This class has an elaborate hash code generation that is much more random than Sun's standard generator, but takes more time. For very large numbers of objects, this is a good idea, but we may change it to a simpler version in the future.
Int3D.equals(...) can compare by value against other Int3Ds and Double3Ds.
- See Also:
- Serialized Form
Field Summary |
int |
x
|
int |
y
|
int |
z
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
x
public final int x
y
public final int y
z
public final int z
Int3D
public Int3D()
Int3D
public Int3D(int x,
int y,
int z)
Int3D
public Int3D(Int2D p)
- Explicitly assumes the z value is set to 0
Int3D
public Int3D(Int2D p,
int z)
getX
public final int getX()
getY
public final int getY()
getZ
public final int getZ()
toString
public java.lang.String toString()
toCoordinates
public java.lang.String toCoordinates()
hashCodeFor
public static final int hashCodeFor(int x,
int y,
int z)
hashCode
public int hashCode()
equals
public boolean equals(java.lang.Object obj)