Package xal.tools

Class ArrayTool

java.lang.Object
xal.tools.ArrayTool

public class ArrayTool extends Object
ArrayTool is a class that adds common convenience methods for dealing with arrays. In particular, it has static methods for dealing with multi-dimensional arrays.
Author:
tap
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new instance of ArrayUtil
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    asString(byte[] array)
    convenience method for getting a string description of an integer array
    static String
    asString(double[] array)
    convenience method for getting a string description of a double array
    static String
    asString(double[][] array)
    convenience method for getting a string description of a double two dimensional array
    static String
    asString(float[] array)
    convenience method for getting a string description of an integer array
    static String
    asString(int[] array)
    convenience method for getting a string description of an integer array
    static String
    asString(long[] array)
    convenience method for getting a string description of an integer array
    static String
    asString(short[] array)
    convenience method for getting a string description of an integer array
    static String
    asString(Object[] array)
    convenience method for getting a string description of an Object array by joining each element with a comma character
    protected static Object
    getBaseArray(Object array, int[] indices, int indexPtr)
    Return the array at the base of the the specified array.
    static double
    getDouble(Object array, int[] indices)
    Given a multi-dimensional array, return the double value at the specified index.
    static Object
    getObject(Object array, int[] indices)
    Given a multi-dimensional array, return the Object at the specified index.
    static boolean
    increment(int[] indices, int[] dimensions)
    Increment the indices in place.
    static void
    setDouble(Object array, int[] indices, double value)
    Given a multi-dimensional array, set the double value at the specified index.
    static void
    setObject(Object array, int[] indices, Object value)
    Given a multi-dimensional array, set the Object at the specified index.

    Methods inherited from class java.lang.Object

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

    • ArrayTool

      protected ArrayTool()
      Creates a new instance of ArrayUtil
  • Method Details

    • getDouble

      public static double getDouble(Object array, int[] indices)
      Given a multi-dimensional array, return the double value at the specified index.
    • setDouble

      public static void setDouble(Object array, int[] indices, double value)
      Given a multi-dimensional array, set the double value at the specified index.
    • getObject

      public static Object getObject(Object array, int[] indices)
      Given a multi-dimensional array, return the Object at the specified index.
    • setObject

      public static void setObject(Object array, int[] indices, Object value)
      Given a multi-dimensional array, set the Object at the specified index.
    • getBaseArray

      protected static Object getBaseArray(Object array, int[] indices, int indexPtr)
      Return the array at the base of the the specified array.
    • increment

      public static boolean increment(int[] indices, int[] dimensions)
      Increment the indices in place. The lower bounds of each index is 0. The upper bound of each index is given by the size of the associated dimension. Indices are incremented in the same way that a multi-dimensional C array would be incremented. Namely, the outer most index is the fast index.
      Parameters:
      indices - the indices are the set of indices to increment
      dimensions - each element is the size of each dimension
      Returns:
      true if the indices were incremented, or false if the indices were not incremented thus indicating that it has exhausted all possible indices.
    • asString

      public static String asString(byte[] array)
      convenience method for getting a string description of an integer array
    • asString

      public static String asString(int[] array)
      convenience method for getting a string description of an integer array
    • asString

      public static String asString(short[] array)
      convenience method for getting a string description of an integer array
    • asString

      public static String asString(long[] array)
      convenience method for getting a string description of an integer array
    • asString

      public static String asString(float[] array)
      convenience method for getting a string description of an integer array
    • asString

      public static String asString(double[] array)
      convenience method for getting a string description of a double array
    • asString

      public static String asString(Object[] array)
      convenience method for getting a string description of an Object array by joining each element with a comma character
      Parameters:
      array - The array of objects
      Returns:
      A string representation of the array
    • asString

      public static String asString(double[][] array)
      convenience method for getting a string description of a double two dimensional array