Class ArrayIndex


  • public class ArrayIndex
    extends java.lang.Object
    This class defines an associative array and methods to store and retrieve data in the array.
    Since:
    Ptolemy II 0.4
    Version:
    $Id$
    Author:
    Bart Kienhuis
    Pt.AcceptedRating:
    Red (kienhuis)
    Pt.ProposedRating:
    Red (kienhuis)
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayIndex()
      Construct an ArrayIndex object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String atKey​(int i_1)
      Create a key for an 1 dimensional index reference.
      java.lang.String atKey​(int i_1, int i_2)
      Create a key for an 2 dimensional index reference.
      java.lang.String atKey​(int i_1, int i_2, int i_3)
      Create a key for an 3 dimensional index reference.
      java.lang.String atKey​(int i_1, int i_2, int i_3, int i_4)
      Create a key for an 4 dimensional index reference.
      java.lang.String atKey​(int i_1, int i_2, int i_3, int i_4, int i_5)
      Create a key for an 5 dimensional index reference.
      java.lang.String atKey​(int i_1, int i_2, int i_3, int i_4, int i_5, int i_6)
      Create a key for an 6 dimensional index reference.
      void readMatrix​(java.lang.String filename)
      Read in a matrix with a given name and store it into a associative data structure.
      double retrieve​(java.lang.String aKey)
      Retrieve a value from the associate array using the supplied key.
      void store​(double aValue, java.lang.String aKey)
      Store a data value at a particular location given by the key string.
      void writeMatrix​(java.lang.String filename)
      Write the matrix stored in the associate array with a given name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArrayIndex

        public ArrayIndex()
        Construct an ArrayIndex object.
    • Method Detail

      • atKey

        public java.lang.String atKey​(int i_1)
        Create a key for an 1 dimensional index reference. This key is used to store and retrieve values in the associate array.
        Parameters:
        i_1 - an index value.
        Returns:
        a key representing the index vector.
      • atKey

        public java.lang.String atKey​(int i_1,
                                      int i_2)
        Create a key for an 2 dimensional index reference. This key is used to store and retrieve values in the associate array.
        Parameters:
        i_1 - an index value.
        i_2 - an index value.
        Returns:
        a key representing the index vector.
      • atKey

        public java.lang.String atKey​(int i_1,
                                      int i_2,
                                      int i_3)
        Create a key for an 3 dimensional index reference. This key is used to store and retrieve values in the associate array.
        Parameters:
        i_1 - an index value.
        i_2 - an index value.
        i_3 - an index value.
        Returns:
        a key representing the index vector.
      • atKey

        public java.lang.String atKey​(int i_1,
                                      int i_2,
                                      int i_3,
                                      int i_4)
        Create a key for an 4 dimensional index reference. This key is used to store and retrieve values in the associate array.
        Parameters:
        i_1 - an index value.
        i_2 - an index value.
        i_3 - an index value.
        i_4 - an index value.
        Returns:
        a key representing the index vector.
      • atKey

        public java.lang.String atKey​(int i_1,
                                      int i_2,
                                      int i_3,
                                      int i_4,
                                      int i_5)
        Create a key for an 5 dimensional index reference. This key is used to store and retrieve values in the associate array.
        Parameters:
        i_1 - an index value.
        i_2 - an index value.
        i_3 - an index value.
        i_4 - an index value.
        i_5 - an index value.
        Returns:
        a key representing the index vector.
      • atKey

        public java.lang.String atKey​(int i_1,
                                      int i_2,
                                      int i_3,
                                      int i_4,
                                      int i_5,
                                      int i_6)
        Create a key for an 6 dimensional index reference. This key is used to store and retrieve values in the associate array.
        Parameters:
        i_1 - an index value.
        i_2 - an index value.
        i_3 - an index value.
        i_4 - an index value.
        i_5 - an index value.
        i_6 - an index value.
        Returns:
        a key representing the index vector.
      • retrieve

        public double retrieve​(java.lang.String aKey)
        Retrieve a value from the associate array using the supplied key.
        Parameters:
        aKey - the key.
        Returns:
        the stored value.
      • store

        public void store​(double aValue,
                          java.lang.String aKey)
        Store a data value at a particular location given by the key string.
        Parameters:
        aValue - the value.
        aKey - the key.
      • readMatrix

        public void readMatrix​(java.lang.String filename)
        Read in a matrix with a given name and store it into a associative data structure. The associate data structure make the access of the data simple. Instead of reading from a file system, the method reads from the source matrix supplied by SourceMatrix class. This make the access of the matrix possible inside a Applet.
        Parameters:
        filename - The filename.
      • writeMatrix

        public void writeMatrix​(java.lang.String filename)
        Write the matrix stored in the associate array with a given name. Currently not further implemented.
        Parameters:
        filename - the filename.