Package xal.tools
Class ArrayTool
java.lang.Object
xal.tools.ArrayTool
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic StringasString(byte[] array) convenience method for getting a string description of an integer arraystatic StringasString(double[] array) convenience method for getting a string description of a double arraystatic StringasString(double[][] array) convenience method for getting a string description of a double two dimensional arraystatic StringasString(float[] array) convenience method for getting a string description of an integer arraystatic StringasString(int[] array) convenience method for getting a string description of an integer arraystatic StringasString(long[] array) convenience method for getting a string description of an integer arraystatic StringasString(short[] array) convenience method for getting a string description of an integer arraystatic Stringconvenience method for getting a string description of an Object array by joining each element with a comma characterprotected static ObjectgetBaseArray(Object array, int[] indices, int indexPtr) Return the array at the base of the the specified array.static doubleGiven a multi-dimensional array, return the double value at the specified index.static ObjectGiven a multi-dimensional array, return the Object at the specified index.static booleanincrement(int[] indices, int[] dimensions) Increment the indices in place.static voidGiven a multi-dimensional array, set the double value at the specified index.static voidGiven a multi-dimensional array, set the Object at the specified index.
-
Constructor Details
-
ArrayTool
protected ArrayTool()Creates a new instance of ArrayUtil
-
-
Method Details
-
getDouble
Given a multi-dimensional array, return the double value at the specified index. -
setDouble
Given a multi-dimensional array, set the double value at the specified index. -
getObject
Given a multi-dimensional array, return the Object at the specified index. -
setObject
Given a multi-dimensional array, set the Object at the specified index. -
getBaseArray
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 incrementdimensions- each element is the size of each dimension- Returns:
trueif the indices were incremented, orfalseif the indices were not incremented thus indicating that it has exhausted all possible indices.
-
asString
convenience method for getting a string description of an integer array -
asString
convenience method for getting a string description of an integer array -
asString
convenience method for getting a string description of an integer array -
asString
convenience method for getting a string description of an integer array -
asString
convenience method for getting a string description of an integer array -
asString
convenience method for getting a string description of a double array -
asString
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
convenience method for getting a string description of a double two dimensional array
-