us.ihmc.utilities
Class ArrayTools

java.lang.Object
  extended by us.ihmc.utilities.ArrayTools

public class ArrayTools
extends java.lang.Object


Constructor Summary
ArrayTools()
           
 
Method Summary
static java.lang.String arrayToString(double[] doubles)
           
static double[] concatentateArrays(double[][] arrayOfArraysToConcatenate)
           
static int[] concatentateArrays(int[][] arrayOfArraysToConcatenate)
           
static java.lang.Object[] concatentateArrays(java.lang.Object[][] arrayOfArraysToConcatenate)
           
static double[] copyArray(double[] array)
          Copys an Array of Doubles
static float[] copyArray(float[] array)
          Copys an Array of Floats
static int[] copyArray(int[] array)
          Copys an Array of intgers
static long[] copyArray(long[] array)
          Copys an Array of Longs
static
<T> T[]
copyArray(T[] array)
           
static boolean deltaEquals(double[] a, double[] b, double delta)
           
static double[] getArrayFromArrayList(java.util.List<java.lang.Double> arrayList)
           
static java.util.ArrayList<java.lang.Double> getArrayListFromArray(double[] array)
           
static double[] getReserveredOrderedArrayCopy(double[] arrayToReverseAndCopy)
           
static
<T> java.util.ArrayList<T>
getReversedArrayList(java.util.ArrayList<T> arrayList)
          Returns the Array in Reverse Order
static double[] parseDoubleArray(java.io.BufferedReader bufferedReader)
           
static double[] parseDoubleArray(java.io.DataInputStream dataInputStream)
           
static double[] parseDoubleArray(java.lang.String stringSource)
           
static double[] parseDoubleArrayFromMATLAB(java.io.BufferedReader bufferedReader)
           
static double[] parseDoubleArrayFromMATLAB(java.lang.String stringSource)
           
static int[] parseIntArray(java.io.DataInputStream dataInputStream)
           
static int[] parseIntegerArray(java.io.BufferedReader bufferedReader)
           
static int[] parseIntegerArray(java.lang.String stringSource)
           
static
<T> void
printArray(java.util.ArrayList<T> arrayList, java.io.PrintStream printStream)
           
static void printArray(boolean[] array)
           
static void printArray(double[][] doubles, java.io.PrintStream printStream)
           
static void printArray(double[] doubles, java.io.DataOutputStream dataOutputStream)
          Prints an Array of doubles with DataOutputStream
static void printArray(double[] doubles, java.io.PrintStream printStream)
          Prints an Array of doubles with PrintStream
static void printArray(double[] doubles, java.io.PrintWriter printWriter)
          Prints an Array of doubles with PrintWriter
static void printArray(double[] doubles, java.io.StringWriter stringWriter)
          Prints an Array of Doubles with StringWriter
static void printArray(int[] ints, java.io.DataOutputStream dataOutputStream)
          Prints an Array of integers with DataOutputStream
static void printArray(int[] ints, java.io.PrintStream printStream)
          Prints an Array of intergers with PrintStream
static void printArray(int[] ints, java.io.PrintWriter printWriter)
          Prints an Array of integers with PrintWriter
static void printArray(int[] ints, java.io.StringWriter stringWriter)
          Prints an Array of integers with StringWriter
static void printArray(java.lang.String[] strings, java.io.PrintStream printStream)
          Prints an Array of Stings with PrintStream
static void printArray(java.lang.String[] strings, java.io.PrintWriter printWriter)
          Prints an Array of strings with PrintWriter
static void printArray(java.lang.String[] strings, java.io.StringWriter stringWriter)
          Prints an Array of strings with StringWriter
static
<T> void
printArray(T[] array)
           
static void printArrayForMATLAB(double[] doubles, java.io.PrintStream printStream)
          Prints an Array of doubles for MATLAB with PrintStream
static void printArrayForMATLAB(double[] doubles, java.io.PrintWriter printWriter)
          Prints an Array of doubles for MATLAB with PrintWriter
static void printArrayForMATLAB(java.lang.String arrayName, double[] doubles, java.io.PrintStream printStream)
          Prints an Array for MATLAB with PrintStream
static void printArrayForMATLAB(java.lang.String arrayName, double[] doubles, java.io.PrintWriter printWriter)
          Prints an Array of doubles for MATLAB with PrintWriter
static void printArrayOfLongs(long[] longs, java.io.StringWriter stringWriter)
          Prints an Array of Longs with StringWriter
static void printIntArray(int[][] ints, java.io.PrintStream printStream)
           
static int[] range(int start, int end)
           
static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> splitArrayIntoEqualishParts(java.util.ArrayList<java.lang.Integer> array, int numberOfParts)
          Returns an arraylist of arraylists each with an equalish part of the original array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayTools

public ArrayTools()
Method Detail

printArrayOfLongs

public static void printArrayOfLongs(long[] longs,
                                     java.io.StringWriter stringWriter)
Prints an Array of Longs with StringWriter

Parameters:
longs - long[]
stringWriter - StringWriter

printArray

public static void printArray(java.lang.String[] strings,
                              java.io.StringWriter stringWriter)
Prints an Array of strings with StringWriter

Parameters:
strings - String[]
stringWriter - StringWriter

printArray

public static void printArray(int[] ints,
                              java.io.StringWriter stringWriter)
Prints an Array of integers with StringWriter

Parameters:
ints - int[]
stringWriter - StringWriter

printArray

public static void printArray(double[] doubles,
                              java.io.StringWriter stringWriter)
Prints an Array of Doubles with StringWriter

Parameters:
doubles - double[]
stringWriter - StringWriter

printArray

public static void printArray(java.lang.String[] strings,
                              java.io.PrintWriter printWriter)
Prints an Array of strings with PrintWriter

Parameters:
strings - String[]
printWriter - PrintWriter

printArray

public static void printArray(java.lang.String[] strings,
                              java.io.PrintStream printStream)
Prints an Array of Stings with PrintStream

Parameters:
strings - String[]
printStream - PrintStream

printArray

public static <T> void printArray(java.util.ArrayList<T> arrayList,
                                  java.io.PrintStream printStream)

printArrayForMATLAB

public static void printArrayForMATLAB(double[] doubles,
                                       java.io.PrintWriter printWriter)
Prints an Array of doubles for MATLAB with PrintWriter

Parameters:
doubles - double[]
printWriter - PrintWriter

printArrayForMATLAB

public static void printArrayForMATLAB(double[] doubles,
                                       java.io.PrintStream printStream)
Prints an Array of doubles for MATLAB with PrintStream

Parameters:
doubles - double[]
printStream - PrintStream

printArrayForMATLAB

public static void printArrayForMATLAB(java.lang.String arrayName,
                                       double[] doubles,
                                       java.io.PrintWriter printWriter)
Prints an Array of doubles for MATLAB with PrintWriter

Parameters:
arrayName - String
doubles - double[]
printWriter - PrintWriter

printArrayForMATLAB

public static void printArrayForMATLAB(java.lang.String arrayName,
                                       double[] doubles,
                                       java.io.PrintStream printStream)
Prints an Array for MATLAB with PrintStream

Parameters:
arrayName - String
doubles - double[]
printStream - PrintStream

printArray

public static void printArray(double[] doubles,
                              java.io.DataOutputStream dataOutputStream)
                       throws java.io.IOException
Prints an Array of doubles with DataOutputStream

Parameters:
doubles - double[]
dataOutputStream - DataOutputStream
Throws:
java.io.IOException

printArray

public static void printArray(double[] doubles,
                              java.io.PrintWriter printWriter)
Prints an Array of doubles with PrintWriter

Parameters:
doubles - double[]
printWriter - PrintWriter

arrayToString

public static java.lang.String arrayToString(double[] doubles)

printArray

public static void printArray(double[] doubles,
                              java.io.PrintStream printStream)
Prints an Array of doubles with PrintStream

Parameters:
doubles - double[]
printStream - PrintStream

printArray

public static void printArray(double[][] doubles,
                              java.io.PrintStream printStream)
Parameters:
doubles - double[][]
printStream - PrintStream

printArray

public static void printArray(int[] ints,
                              java.io.PrintWriter printWriter)
Prints an Array of integers with PrintWriter

Parameters:
ints - int[]
printWriter - PrintWriter

printArray

public static void printArray(int[] ints,
                              java.io.PrintStream printStream)
Prints an Array of intergers with PrintStream

Parameters:
ints - int[]
printStream - PrintStream

printArray

public static void printArray(int[] ints,
                              java.io.DataOutputStream dataOutputStream)
                       throws java.io.IOException
Prints an Array of integers with DataOutputStream

Parameters:
ints - int[]
dataOutputStream - DataOutputStream
Throws:
java.io.IOException

printIntArray

public static void printIntArray(int[][] ints,
                                 java.io.PrintStream printStream)
Parameters:
ints - int[][]
printStream - PrintStream

parseDoubleArray

public static double[] parseDoubleArray(java.lang.String stringSource)
                                 throws java.io.IOException
Parameters:
stringSource - String
Returns:
double[]
Throws:
java.io.IOException

parseDoubleArray

public static double[] parseDoubleArray(java.io.BufferedReader bufferedReader)
                                 throws java.io.IOException
Parameters:
bufferedReader - BufferedReader
Returns:
double[]
Throws:
java.io.IOException

parseDoubleArrayFromMATLAB

public static double[] parseDoubleArrayFromMATLAB(java.lang.String stringSource)
                                           throws java.io.IOException
Parameters:
stringSource - String
Returns:
double[]
Throws:
java.io.IOException

parseDoubleArrayFromMATLAB

public static double[] parseDoubleArrayFromMATLAB(java.io.BufferedReader bufferedReader)
                                           throws java.io.IOException
Parameters:
bufferedReader - BufferedReader
Returns:
double[]
Throws:
java.io.IOException

parseDoubleArray

public static double[] parseDoubleArray(java.io.DataInputStream dataInputStream)
                                 throws java.io.IOException
Throws:
java.io.IOException

parseIntegerArray

public static int[] parseIntegerArray(java.lang.String stringSource)
                               throws java.io.IOException
Throws:
java.io.IOException

parseIntegerArray

public static int[] parseIntegerArray(java.io.BufferedReader bufferedReader)
                               throws java.io.IOException
Throws:
java.io.IOException

parseIntArray

public static int[] parseIntArray(java.io.DataInputStream dataInputStream)
                           throws java.io.IOException
Throws:
java.io.IOException

copyArray

public static float[] copyArray(float[] array)
Copys an Array of Floats

Parameters:
array - float[]
Returns:
float[]

copyArray

public static double[] copyArray(double[] array)
Copys an Array of Doubles

Parameters:
array - double[]
Returns:
double[]

copyArray

public static int[] copyArray(int[] array)
Copys an Array of intgers

Parameters:
array - int[]
Returns:
int[]

copyArray

public static <T> T[] copyArray(T[] array)

getReserveredOrderedArrayCopy

public static double[] getReserveredOrderedArrayCopy(double[] arrayToReverseAndCopy)

copyArray

public static long[] copyArray(long[] array)
Copys an Array of Longs

Parameters:
array - long[]
Returns:
long[]

concatentateArrays

public static int[] concatentateArrays(int[][] arrayOfArraysToConcatenate)
Parameters:
arrayOfArraysToConcatenate - int[][]
Returns:
int[]

concatentateArrays

public static double[] concatentateArrays(double[][] arrayOfArraysToConcatenate)
Parameters:
arrayOfArraysToConcatenate - double[][]
Returns:
double[]

concatentateArrays

public static java.lang.Object[] concatentateArrays(java.lang.Object[][] arrayOfArraysToConcatenate)
Parameters:
arrayOfArraysToConcatenate - Object[][]
Returns:
Object[]

printArray

public static <T> void printArray(T[] array)

deltaEquals

public static boolean deltaEquals(double[] a,
                                  double[] b,
                                  double delta)

getReversedArrayList

public static <T> java.util.ArrayList<T> getReversedArrayList(java.util.ArrayList<T> arrayList)
Returns the Array in Reverse Order

Parameters:
arrayList - ArrayList
Returns:
ArrayList

getArrayListFromArray

public static java.util.ArrayList<java.lang.Double> getArrayListFromArray(double[] array)

getArrayFromArrayList

public static double[] getArrayFromArrayList(java.util.List<java.lang.Double> arrayList)

splitArrayIntoEqualishParts

public static java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> splitArrayIntoEqualishParts(java.util.ArrayList<java.lang.Integer> array,
                                                                                                      int numberOfParts)
Returns an arraylist of arraylists each with an equalish part of the original array. The overall ordering of the objects is unchanged.

Parameters:
array - ArrayList
numberOfParts - int
Returns:
ArrayList

range

public static int[] range(int start,
                          int end)

printArray

public static void printArray(boolean[] array)