coreEngine.Helper.CompressArray

## Class CA3DString

- java.lang.Object
- - coreEngine.Helper.CompressArray.CA3DString

- All Implemented Interfaces:
    java.io.Serializable

      public class CA3DString
      extends java.lang.Object
      implements java.io.Serializable

  Compressed 3-D String array (line compression version). This array cost same amount of memory at runtime, but is compressed in serialization. This class provides several utility functions for changing value in the array. Ideal when the data in the array is well organized.
  Author:
    Shu Liu
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.lang.String[][][]` | `fullMatrix` 3D array contains the full matrix
    `private java.lang.String[]` | `lineNum` Array of unique numbers for compression
    `private int[]` | `lineRep` Array of number of repetitions for compression
    `private static long` | `serialVersionUID` serialVersionUID
    `private int` | `sizeX` Size of the first index
    `private int` | `sizeY` Size of the second index
    `private int` | `sizeZ` Size of the third index

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CA3DString(int sizeX, int sizeY, int sizeZ, java.lang.String defaultValue)` Constructor of compress 3D array

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(java.lang.String value, int x, int y, int z)` Add a value to a single location in the array
    `void` | `add(java.lang.String value, int fromX, int fromY, int fromZ, int toX, int toY, int toZ)` Add a value to a region in the array
    `private void` | `compressMatrix()` Prepare compressed data from full matrix to write out
    `void` | `deepCopyFrom(CA3DString matrix)` Initialize a compressed matrix by creating a deep copy
    `private void` | `expandMatrix()` Expand compressed data to full matrix
    `java.lang.String` | `get(int x, int y, int z)` Get a single value from the array
    `int` | `getSizeX()` Getter for the size of first dimension
    `int` | `getSizeY()` Getter for the size of second dimension
    `int` | `getSizeZ()` Getter for the size of third dimension
    `private void` | `readObject(java.io.ObjectInputStream in)` Read object from input stream
    `void` | `set(java.lang.String value, int x, int y, int z)` Set a value to a single location in the array
    `void` | `set(java.lang.String value, int fromX, int fromY, int fromZ, int toX, int toY, int toZ)` Set a value to a region in the array
    `private void` | `writeObject(java.io.ObjectOutputStream out)` Write object to output stream

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### serialVersionUID

          private static final long serialVersionUID

      serialVersionUID
      See Also:
        Constant Field Values

    - #### sizeX

          private int sizeX

      Size of the first index

    - #### sizeY

          private int sizeY

      Size of the second index

    - #### sizeZ

          private int sizeZ

      Size of the third index

    - #### fullMatrix

          private java.lang.String[][][] fullMatrix

      3D array contains the full matrix

    - #### lineNum

          private java.lang.String[] lineNum

      Array of unique numbers for compression

    - #### lineRep

          private int[] lineRep

      Array of number of repetitions for compression

  - ### Constructor Detail

    - #### CA3DString

          public CA3DString(int sizeX,
                            int sizeY,
                            int sizeZ,
                            java.lang.String defaultValue)

      Constructor of compress 3D array
      Parameters:
        `sizeX` - size of the first index
        `sizeY` - size of the second index
        `sizeZ` - size of the third index
        `defaultValue` - default value in the array

  - ### Method Detail

    - #### set

          public void set(java.lang.String value,
                          int x,
                          int y,
                          int z)

      Set a value to a single location in the array
      Parameters:
        `value` - new value
        `x` - first index
        `y` - second index
        `z` - third index

    - #### set

          public void set(java.lang.String value,
                          int fromX,
                          int fromY,
                          int fromZ,
                          int toX,
                          int toY,
                          int toZ)

      Set a value to a region in the array
      Parameters:
        `value` - new value
        `fromX` - from first index (inclusive)
        `fromY` - from second index (inclusive)
        `fromZ` - from third index (inclusive)
        `toX` - to first index (inclusive)
        `toY` - to second index (inclusive)
        `toZ` - to third index (inclusive)

    - #### add

          public void add(java.lang.String value,
                          int x,
                          int y,
                          int z)

      Add a value to a single location in the array
      Parameters:
        `value` - value to be added
        `x` - first index
        `y` - second index
        `z` - third index

    - #### add

          public void add(java.lang.String value,
                          int fromX,
                          int fromY,
                          int fromZ,
                          int toX,
                          int toY,
                          int toZ)

      Add a value to a region in the array
      Parameters:
        `value` - value to be added
        `fromX` - from first index (inclusive)
        `fromY` - from second index (inclusive)
        `fromZ` - from third index (inclusive)
        `toX` - to first index (inclusive)
        `toY` - to second index (inclusive)
        `toZ` - to third index (inclusive)

    - #### get

          public java.lang.String get(int x,
                                      int y,
                                      int z)

      Get a single value from the array
      Parameters:
        `x` - first index
        `y` - second index
        `z` - third index
      Returns:
        a single value from the array

    - #### getSizeX

          public int getSizeX()

      Getter for the size of first dimension
      Returns:
        size of first dimension

    - #### getSizeY

          public int getSizeY()

      Getter for the size of second dimension
      Returns:
        size of second dimension

    - #### getSizeZ

          public int getSizeZ()

      Getter for the size of third dimension
      Returns:
        size of third dimension

    - #### writeObject

          private void writeObject(java.io.ObjectOutputStream out)
                            throws java.io.IOException

      Write object to output stream
      Parameters:
        `out` - object output stream
      Throws:
        `java.io.IOException`

    - #### readObject

          private void readObject(java.io.ObjectInputStream in)
                           throws java.io.IOException,
                                  java.lang.ClassNotFoundException

      Read object from input stream
      Parameters:
        `in` - object input stream
      Throws:
        `java.io.IOException`
        `java.lang.ClassNotFoundException`

    - #### compressMatrix

          private void compressMatrix()

      Prepare compressed data from full matrix to write out

    - #### expandMatrix

          private void expandMatrix()

      Expand compressed data to full matrix

    - #### deepCopyFrom

          public void deepCopyFrom(CA3DString matrix)

      Initialize a compressed matrix by creating a deep copy
      Parameters:
        `matrix` - matrix to be copied from