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
FieldsModifier and TypeFieldDescriptionprotected static final byteprotected static final byteprotected static final byteprotected static final byteprotected static final byteprotected static final byteprotected static final byteprotected static final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static doubledoubleFromBytes(byte[] buf, int pos) Unloads the value in MSB first, LSB last order.protected static voiddoubleToBytes(double val, byte[] buf, int pos) Loads the value in MSB first, LSB last order.abstract booleanReturns whether this NumberND is equivalent to some other NumberND.protected static NumberNDfromBytes(byte[] bytes) Produces a NumberND from the provided array of bytes, which should have been generated by NumberND.toBytes()doublegetDistanceSq(NumberND that) double[]getOffsets(NumberND that) abstract doublegetVal(int pos) Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)abstract inthashCode()Provides a hashcode for this NumberND.protected static intintFromBytes(byte[] buf, int pos) Unloads the value in MSB first, LSB last order.protected static voidintToBytes(int val, byte[] buf, int pos) Loads the value in MSB first, LSB last order.static voidbooleanmutable()Returns whether this NumberND is mutable.abstract intReturns 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 StringReturns this NumberND in mathematical coordinates as a formatted String.abstract StringtoString()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
-