Module Simula

Class RTS_ARRAY

java.lang.Object
simula.runtime.RTS_ARRAY
Direct Known Subclasses:
RTS_RTObject.RTS_BOOLEAN_ARRAY, RTS_RTObject.RTS_CHARACTER_ARRAY, RTS_RTObject.RTS_INTEGER_ARRAY, RTS_RTObject.RTS_REALTYPE_ARRAY, RTS_RTObject.RTS_REF_ARRAY, RTS_RTObject.RTS_TEXT_ARRAY

public abstract class RTS_ARRAY extends Object
Utility class ARRAY.

This class provides an abstract superclass for Simula arrays. The implementation technique used is called 'dope vector indexing'. The dope vector is calculated in the constructor based on the array bound pairs. A fictitious base is also Calculated. This base is the relative address of the array element (0,0, ... 0).

See Mapping Simula to Java (runtime design) Sect. 3.4 Array Quantities

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    The fictitious base.
    The initilal BOUND pairs
    private final int[]
    The DOPE Vector
    final int
    The initial calculated SIZE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an _ARRAY with the given BOUNDS.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract RTS_ARRAY
    Abstract method redefined for all subclass <type>_ARRAY
    int
    index(int... x)
    General method to calculate index to the ELT array.
    int
    lowerBound(int i)
    The procedure "lowerbound" returns the lower (upper) bound of the dimension of the given array corresponding to the given index.
    int
    Returns the number of dimensions for this _ARRAY
    int
    Return the size of the underlying ELT[] array
    Returns a string representation of the object.
    int
    upperBound(int i)
    The procedure "upperbound" returns the lower (upper) bound of the dimension of the given array corresponding to the given index.

    Methods inherited from class java.lang.Object

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

    • BOUNDS

      public final RTS_RTObject.RTS_BOUNDS[] BOUNDS
      The initilal BOUND pairs
    • SIZE

      public final int SIZE
      The initial calculated SIZE
    • BASE

      private final int BASE
      The fictitious base. This base is the relative address of the array element (0,0, ... 0).
    • DOPE

      private final int[] DOPE
      The DOPE Vector
  • Constructor Details

    • RTS_ARRAY

      public RTS_ARRAY(RTS_RTObject.RTS_BOUNDS... BOUNDS)
      Create an _ARRAY with the given BOUNDS.
      Parameters:
      BOUNDS - the ARRAY BOUNDS
  • Method Details

    • nDim

      public int nDim()
      Returns the number of dimensions for this _ARRAY
      Returns:
      the number of dimensions
    • size

      public int size()
      Return the size of the underlying ELT[] array
      Returns:
      the size of the underlying ELT[] array
    • lowerBound

      public int lowerBound(int i)
      The procedure "lowerbound" returns the lower (upper) bound of the dimension of the given array corresponding to the given index. The first dimension has index one, the next two, etc. An index less than one or greater than the number of dimensions of the given array constitutes a run time error
      Parameters:
      i - the given index
      Returns:
      lowerbound of index i
    • upperBound

      public int upperBound(int i)
      The procedure "upperbound" returns the lower (upper) bound of the dimension of the given array corresponding to the given index. The first dimension has index one, the next two, etc. An index less than one or greater than the number of dimensions of the given array constitutes a run time error
      Parameters:
      i - the given index
      Returns:
      upperbound of index i
    • COPY

      public abstract RTS_ARRAY COPY()
      Abstract method redefined for all subclass <type>_ARRAY
      Returns:
      a copy of this _ARRAY
    • index

      public int index(int... x)
      General method to calculate index to the ELT array.
      Parameters:
      x - the indicies
      Returns:
      the calculated index
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object