papaya
Class Cast

java.lang.Object
  extended by papaya.Cast

public final class Cast
extends Object

Static Class for casting Object arrays to their corresponding primitive type. Similar to the toArray(T[] a) method specified in the java Collections interface, but for float[] and int[] arrays (as opposed to Float[] and Integer[]).

Author:
Nur Adila Faruk Senan

Method Summary
static float[] arrayListToFloat(ArrayList<Float> _inputDat)
          function for casting ArrayList to float[]
static int[] arrayListToInt(ArrayList<Integer> _inputDat)
          function for casting ArrayList to int[]
static float[] doubleToFloat(double[] _inputDat)
          function for casting double[] to float[]
static float[][] doubleToFloat(double[][] _inputDat)
          function for casting double[][] to float[][]
static double[] floatToDouble(float[] _inputDat)
          function for casting float[] to double[]
static double[][] floatToDouble(float[][] _inputDat)
          function for casting float[][] to double[][]
static PVector[] floatToPVector(float[] x, float[] y)
          Returns a PVector array with the x, and coordinates set to the input values, and the z coordinates set to zero.
static PVector[] floatToPVector(float[] x, float[] y, float[] z)
          Returns a PVector array with the x, y, and z coordinates set to the input values (technically not a cast, but a reorganization).
static float[] keySetToFloat(HashMap _hMap)
          Function for casting hashMap keySet to float[]
static int[] keySetToInt(HashMap _hMap)
          Function for casting hashMap keySet to float[]
static String[] keySetToString(HashMap _hMap)
          Function for casting hashMap keySet to String[]
static float[] setToFloat(Set<Float> theSet)
          Function for casting a Set to float[]
static int[] setToInt(Set<Integer> theSet)
          Function for casting a Set to float[]
static String[] setToString(Set<String> theSet)
          Function for casting a Set to String array.
static float[] vectorToFloat(Vector<Float> _inputDat)
          function for casting Vector to float[]
static int[] vectorToInt(Vector<Integer> _inputDat)
          function for casting Vector to int[]
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

arrayListToInt

public static int[] arrayListToInt(ArrayList<Integer> _inputDat)
function for casting ArrayList to int[]

Parameters:
_inputDat - ArrayList array that needs to be cast to int[]
Returns:
the resulting int[] array

arrayListToFloat

public static float[] arrayListToFloat(ArrayList<Float> _inputDat)
function for casting ArrayList to float[]

Parameters:
_inputDat - ArrayList array that needs to be cast to float[]
Returns:
the resulting float[] array

floatToDouble

public static double[][] floatToDouble(float[][] _inputDat)
function for casting float[][] to double[][]

Parameters:
_inputDat - float[][] 2d array
Returns:
deep copy of _inputDat with each element cast to a double

floatToDouble

public static double[] floatToDouble(float[] _inputDat)
function for casting float[] to double[]

Parameters:
_inputDat - float[] array
Returns:
deep copy of _inputDat with each element cast to a double

doubleToFloat

public static float[][] doubleToFloat(double[][] _inputDat)
function for casting double[][] to float[][]

Parameters:
_inputDat - double[][] 2d array
Returns:
deep copy of _inputDat with each element cast to a float

doubleToFloat

public static float[] doubleToFloat(double[] _inputDat)
function for casting double[] to float[]

Parameters:
_inputDat - double[] array
Returns:
deep copy of _inputDat with each element cast to a float

keySetToString

public static String[] keySetToString(HashMap _hMap)
Function for casting hashMap keySet to String[]

Parameters:
_hMap - input HashMap
Returns:
Hashmap.keySet() cast to String[] Use only for the case where the HashMap Keys are Strings

keySetToInt

public static int[] keySetToInt(HashMap _hMap)
Function for casting hashMap keySet to float[]

Parameters:
_hMap - input HashMap
Returns:
Hashmap.keySet() cast to float[] Use only for the case where the HashMap Keys are floats

keySetToFloat

public static float[] keySetToFloat(HashMap _hMap)
Function for casting hashMap keySet to float[]

Parameters:
_hMap - input HashMap
Returns:
Hashmap.keySet() cast to float[] Use only for the case where the HashMap Keys are floats

setToInt

public static int[] setToInt(Set<Integer> theSet)
Function for casting a Set to float[]


setToFloat

public static float[] setToFloat(Set<Float> theSet)
Function for casting a Set to float[]


setToString

public static String[] setToString(Set<String> theSet)
Function for casting a Set to String array. This is really just one line of code, but it's much easier to have it as an external function rather than having to remember it


vectorToInt

public static int[] vectorToInt(Vector<Integer> _inputDat)
function for casting Vector to int[]

Parameters:
_inputDat - Vector array that needs to be cast to int[]
Returns:
the resulting int[] array

vectorToFloat

public static float[] vectorToFloat(Vector<Float> _inputDat)
function for casting Vector to float[]

Parameters:
_inputDat - Vector array that needs to be cast to float[]
Returns:
the resulting float[] array

floatToPVector

public static PVector[] floatToPVector(float[] x,
                                       float[] y,
                                       float[] z)
Returns a PVector array with the x, y, and z coordinates set to the input values (technically not a cast, but a reorganization).


floatToPVector

public static PVector[] floatToPVector(float[] x,
                                       float[] y)
Returns a PVector array with the x, and coordinates set to the input values, and the z coordinates set to zero. (technically not a cast, but a reorganization).



Processing library papaya by Adila Faruk. (C) 2014