| java.lang.Object uk.org.ponder.arrayutil.ArrayUtil
ArrayUtil | public class ArrayUtil (Code) | | This class supplies a selection of useful methods to operate on Java arrays.
With these methods, arrays can behave very much like Vectors, only with much
greater time and space efficiency where the length is short or modifications
are infrequent.
|
Method Summary | |
final public static Object[] | append(Object[] array1, Object toappend) Appends a single object to the end of the supplied array, returning an
array one element longer than the supplied array.
Parameters: array1 - The array to which the element is to be appended, ornull if no array yet exists. Parameters: toappend - The object to be appended to the array. | final public static Object[] | concat(Object[] array1, Object[] array2) Concatenates two arrays of the same reference type to return a larger
array.
Parameters: array1 - The first array to be concatenated. Parameters: array2 - The second array to be concatenated. | final public static boolean | contains(Object[] array, Object tofind) Determines whether the supplied array contains a given element. | public static boolean | equals(String string, char[] buffer, int start, int length) | final public static Object[] | expand(Object[] array1, double scalefactor) Expands the supplied array by the given factor, to return an array with the
same contents padded by null.
Parameters: array1 - The array to be expanded. Parameters: scalefactor - The factor the size of the array is to be enlarged by -clearly this must be a number greater than 1.0. | final public static Object[] | expand(Object[] array1, int newsize) Expands the supplied array to the specified size, to return an array with
the same contents padded by null.
Parameters: array1 - The array to be expanded. Parameters: newsize - The required size of the array. | final public static byte[] | expand(byte[] array1, double scalefactor) Expands the supplied array by the given factor, to return an array with the
same contents padded by null.
Parameters: array1 - The array to be expanded. Parameters: scalefactor - The factor the size of the array is to be enlarged by -clearly this must be a number greater than 1.0. | final public static int | indexOf(Object[] array, Object tofind) Finds the first index that the supplied element appears at in a given
array. | final public static int | indexOf(int[] array, int tofind) Finds the first index that the supplied element appears at in a given
array. | public static int | lexicalCompare(Comparable[] array1, int length1, Comparable[] array2, int length2) | final public static Object[] | removeElementAt(Object[] array, int index) | final public static void | removeElementAtShift(Object[] array, int index) Removes an element from an array, by causing all the elements beyond it to
shuffle back one place.
Parameters: array - The array from which the element is to be removed. Parameters: index - The index from which the element is to be removed. | final public static Object[] | subArray(Object[] array1, int start, int end) Returns a sub-array whose elements are copied from a range of the entries
in the supplied array.
Parameters: array1 - The source array Parameters: tolength - The number of elements to be returned from the beginning ofthe array. | final public static String | toString(Object[] array) Converts the supplied array into a String for debugging purposes. | final public static Object[] | trim(Object[] array1, int tolength) Trims the supplied array to the specified size, to return an array with
only the elements from the first portion of the supplied array.
Parameters: array1 - The array to be trimmed. Parameters: tolength - The number of elements to be returned from the beginning ofthe array. |
doubleArrayClass | public static Class doubleArrayClass(Code) | | |
stringArrayClass | public static Class stringArrayClass(Code) | | |
append | final public static Object[] append(Object[] array1, Object toappend)(Code) | | Appends a single object to the end of the supplied array, returning an
array one element longer than the supplied array.
Parameters: array1 - The array to which the element is to be appended, ornull if no array yet exists. Parameters: toappend - The object to be appended to the array. A new array one element longer than the supplied array, with thesupplied object copied into the final place. |
concat | final public static Object[] concat(Object[] array1, Object[] array2)(Code) | | Concatenates two arrays of the same reference type to return a larger
array.
Parameters: array1 - The first array to be concatenated. Parameters: array2 - The second array to be concatenated. An array whose length is the sum of the lengths of the inputarrays, and contains the elements of the second array appended tothe elements of the first. |
contains | final public static boolean contains(Object[] array, Object tofind)(Code) | | Determines whether the supplied array contains a given element. Equality
will be determined by the .equals() method.
Parameters: array - The array to be searched for the supplied element. Parameters: tofind - The element to be found in the array. true if the element was found in the array. |
equals | public static boolean equals(String string, char[] buffer, int start, int length)(Code) | | |
expand | final public static Object[] expand(Object[] array1, double scalefactor)(Code) | | Expands the supplied array by the given factor, to return an array with the
same contents padded by null.
Parameters: array1 - The array to be expanded. Parameters: scalefactor - The factor the size of the array is to be enlarged by -clearly this must be a number greater than 1.0. An array with the required size, with the contents of the suppliedarray copied into its first portion. |
expand | final public static Object[] expand(Object[] array1, int newsize)(Code) | | Expands the supplied array to the specified size, to return an array with
the same contents padded by null.
Parameters: array1 - The array to be expanded. Parameters: newsize - The required size of the array. An array with the required size, with the contents of the suppliedarray copied into its first portion. |
expand | final public static byte[] expand(byte[] array1, double scalefactor)(Code) | | Expands the supplied array by the given factor, to return an array with the
same contents padded by null.
Parameters: array1 - The array to be expanded. Parameters: scalefactor - The factor the size of the array is to be enlarged by -clearly this must be a number greater than 1.0. An array with the required size, with the contents of the suppliedarray copied into its first portion. |
indexOf | final public static int indexOf(Object[] array, Object tofind)(Code) | | Finds the first index that the supplied element appears at in a given
array. Equality will be determined by the .equals() method.
Parameters: array - The array to be searched for the supplied element. Parameters: tofind - The object to be searched for. The first index that the object appears at in the array, or-1 if it is not found. |
indexOf | final public static int indexOf(int[] array, int tofind)(Code) | | Finds the first index that the supplied element appears at in a given
array. Equality will be determined by the .equals() method.
Parameters: array - The array to be searched for the supplied element. Parameters: tofind - The object to be searched for. The first index that the object appears at in the array, or-1 if it is not found. |
removeElementAt | final public static Object[] removeElementAt(Object[] array, int index)(Code) | | |
removeElementAtShift | final public static void removeElementAtShift(Object[] array, int index)(Code) | | Removes an element from an array, by causing all the elements beyond it to
shuffle back one place.
Parameters: array - The array from which the element is to be removed. Parameters: index - The index from which the element is to be removed. The same array that was input, with the elements past the specifiedindex shuffled back one place. |
subArray | final public static Object[] subArray(Object[] array1, int start, int end)(Code) | | Returns a sub-array whose elements are copied from a range of the entries
in the supplied array.
Parameters: array1 - The source array Parameters: tolength - The number of elements to be returned from the beginning ofthe array. An array containing the elements from index start (inclusive) to index end (not inclusive) from thesource array. |
toString | final public static String toString(Object[] array)(Code) | | Converts the supplied array into a String for debugging purposes.
A String formed from the results of the .toString() method on each array element, separated by single space characters.If the supplied array is null, returns the string null . |
trim | final public static Object[] trim(Object[] array1, int tolength)(Code) | | Trims the supplied array to the specified size, to return an array with
only the elements from the first portion of the supplied array.
Parameters: array1 - The array to be trimmed. Parameters: tolength - The number of elements to be returned from the beginning ofthe array. An array containing only the first tolength elementsof the supplied array. |
|
|