Package sim.util
Class NumberND
java.lang.Object
sim.util.NumberND
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
MutableNumberND
,Number2D
,Number3D
NumberND is the top-level abstract class of MASON's 2D and 3D mutable and immutable ints and doubles.
All NumberND classes are Serializable
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final byte
protected static final byte
protected static final byte
protected static final byte
protected static final byte
protected static final byte
protected static final byte
protected static final byte
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static double
doubleFromBytes
(byte[] buf, int pos) Unloads the value in MSB first, LSB last order.protected static void
doubleToBytes
(double val, byte[] buf, int pos) Loads the value in MSB first, LSB last order.abstract boolean
Returns whether this NumberND is equivalent to some other NumberND.protected static NumberND
fromBytes
(byte[] bytes) Produces a NumberND from the provided array of bytes, which should have been generated by NumberND.toBytes()double
getDistanceSq
(NumberND that) double[]
getOffsets
(NumberND that) abstract double
getVal
(int pos) Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)abstract int
hashCode()
Provides a hashcode for this NumberND.protected static int
intFromBytes
(byte[] buf, int pos) Unloads the value in MSB first, LSB last order.protected static void
intToBytes
(int val, byte[] buf, int pos) Loads the value in MSB first, LSB last order.static void
boolean
mutable()
Returns whether this NumberND is mutable.abstract int
Returns the number of dimensions of this NumberND (normally 2 or 3)abstract double[]
abstract byte[]
toBytes()
Flattens out the NumberND to an array of bytes, including the NumberND subtype.abstract String
Returns this NumberND in mathematical coordinates as a formatted String.abstract String
toString()
Returns this NumberND as a nicely formatted String.
-
Field Details
-
TYPE_INT_2D
protected static final byte TYPE_INT_2D- See Also:
-
TYPE_DOUBLE_2D
protected static final byte TYPE_DOUBLE_2D- See Also:
-
TYPE_INT_3D
protected static final byte TYPE_INT_3D- See Also:
-
TYPE_DOUBLE_3D
protected static final byte TYPE_DOUBLE_3D- See Also:
-
TYPE_MUTABLE_INT_2D
protected static final byte TYPE_MUTABLE_INT_2D- See Also:
-
TYPE_MUTABLE_DOUBLE_2D
protected static final byte TYPE_MUTABLE_DOUBLE_2D- See Also:
-
TYPE_MUTABLE_INT_3D
protected static final byte TYPE_MUTABLE_INT_3D- See Also:
-
TYPE_MUTABLE_DOUBLE_3D
protected static final byte TYPE_MUTABLE_DOUBLE_3D- See Also:
-
-
Constructor Details
-
NumberND
public NumberND()
-
-
Method Details
-
numDimensions
public abstract int numDimensions()Returns the number of dimensions of this NumberND (normally 2 or 3) -
toArrayAsDouble
public abstract double[] toArrayAsDouble() -
getVal
public abstract double getVal(int pos) Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2) -
toBytes
public abstract byte[] toBytes()Flattens out the NumberND to an array of bytes, including the NumberND subtype. -
mutable
public boolean mutable()Returns whether this NumberND is mutable. This is equivalent to asking (instanceof val MutableNumberND) -
equals
Returns whether this NumberND is equivalent to some other NumberND. -
hashCode
public abstract int hashCode()Provides a hashcode for this NumberND. -
toString
Returns this NumberND as a nicely formatted String. -
toCoordinates
Returns this NumberND in mathematical coordinates as a formatted String. -
intToBytes
protected static void intToBytes(int val, byte[] buf, int pos) Loads the value in MSB first, LSB last order. -
doubleToBytes
protected static void doubleToBytes(double val, byte[] buf, int pos) Loads the value in MSB first, LSB last order. -
intFromBytes
protected static int intFromBytes(byte[] buf, int pos) Unloads the value in MSB first, LSB last order. -
doubleFromBytes
protected static double doubleFromBytes(byte[] buf, int pos) Unloads the value in MSB first, LSB last order. -
fromBytes
Produces a NumberND from the provided array of bytes, which should have been generated by NumberND.toBytes() -
main
-
getOffsets
-
getDistanceSq
-