Package sim.util

Class NumberND

java.lang.Object
sim.util.NumberND
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MutableNumberND, Number2D, Number3D

public abstract class NumberND extends Object implements Serializable
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

    Fields
    Modifier and Type
    Field
    Description
    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
     
    protected static final byte
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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
     
    double[]
     
    abstract double
    getVal(int pos)
    Returns the value at position VAL in this NumberND (val should 0, 1, or sometimes 2)
    abstract int
    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
    main(String[] args)
     
    boolean
    Returns whether this NumberND is mutable.
    abstract int
    Returns the number of dimensions of this NumberND (normally 2 or 3)
    abstract double[]
     
    abstract byte[]
    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
    Returns this NumberND as a nicely formatted String.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • 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

      public abstract boolean equals(Object obj)
      Returns whether this NumberND is equivalent to some other NumberND.
      Overrides:
      equals in class Object
    • hashCode

      public abstract int hashCode()
      Provides a hashcode for this NumberND.
      Overrides:
      hashCode in class Object
    • toString

      public abstract String toString()
      Returns this NumberND as a nicely formatted String.
      Overrides:
      toString in class Object
    • toCoordinates

      public abstract 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

      protected static NumberND fromBytes(byte[] bytes)
      Produces a NumberND from the provided array of bytes, which should have been generated by NumberND.toBytes()
    • main

      public static void main(String[] args)
    • getOffsets

      public double[] getOffsets(NumberND that)
    • getDistanceSq

      public double getDistanceSq(NumberND that)