You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2009/09/11 20:27:18 UTC
svn commit: r813971 [2/3] - in /commons/proper/lang/trunk/src:
java/org/apache/commons/lang/ArrayUtils.java
test/org/apache/commons/lang/ArrayUtilsAddTest.java
Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ArrayUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/ArrayUtils.java?rev=813971&r1=813970&r2=813971&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/ArrayUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/ArrayUtils.java Fri Sep 11 18:27:18 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,7 @@
/**
* <p>Operations on arrays, primitive arrays (like <code>int[]</code>) and
* primitive wrapper arrays (like <code>Integer[]</code>).</p>
- *
+ *
* <p>This class tries to handle <code>null</code> input gracefully.
* An exception will not be thrown for a <code>null</code>
* array input. However, an Object array that contains a <code>null</code>
@@ -143,7 +143,7 @@
public ArrayUtils() {
super();
}
-
+
// Basic methods handling multi-dimensional arrays
//-----------------------------------------------------------------------
/**
@@ -153,7 +153,7 @@
* multi-dimensional primitive arrays.</p>
*
* <p>The format is that of Java source code, for example <code>{a,b}</code>.</p>
- *
+ *
* @param array the array to get a toString for, may be <code>null</code>
* @return a String representation of the array, '{}' if null array input
*/
@@ -168,11 +168,12 @@
* multi-dimensional primitive arrays.</p>
*
* <p>The format is that of Java source code, for example <code>{a,b}</code>.</p>
- *
+ *
* @param array the array to get a toString for, may be <code>null</code>
* @param stringIfNull the String to return if the array is <code>null</code>
* @return a String representation of the array
- */
+ */
+ @SuppressWarnings("unchecked")
public static String toString(Object array, String stringIfNull) {
if (array == null) {
return stringIfNull;
@@ -182,9 +183,9 @@
/**
* <p>Get a hashCode for an array handling multi-dimensional arrays correctly.</p>
- *
+ *
* <p>Multi-dimensional primitive arrays are also handled correctly by this method.</p>
- *
+ *
* @param array the array to get a hashCode for, may be <code>null</code>
* @return a hashCode for the array, zero if null array input
*/
@@ -195,9 +196,9 @@
/**
* <p>Compares two arrays, using equals(), handling multi-dimensional arrays
* correctly.</p>
- *
+ *
* <p>Multi-dimensional primitive arrays are also handled correctly by this method.</p>
- *
+ *
* @param array1 the left hand array to compare, may be <code>null</code>
* @param array2 the right hand array to compare, may be <code>null</code>
* @return <code>true</code> if the arrays are equal
@@ -222,7 +223,7 @@
* {"GREEN", "#00FF00"},
* {"BLUE", "#0000FF"}});
* </pre>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
*
* @param array an array whose elements are either a {@link java.util.Map.Entry} or
@@ -268,13 +269,13 @@
*
* <p>The objects in the array are not cloned, thus there is no special
* handling for multi-dimensional arrays.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to shallow clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
- public static Object[] clone(Object[] array) {
+ public static <T> T[] clone(T[] array) {
if (array == null) {
return null;
}
@@ -286,7 +287,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -302,7 +303,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -318,7 +319,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -334,7 +335,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -350,7 +351,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -366,7 +367,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -382,7 +383,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -398,7 +399,7 @@
* <code>null</code>.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
@@ -438,7 +439,8 @@
* the start and end indices.
* @since 2.1
*/
- public static Object[] subarray(Object[] array, int startIndexInclusive, int endIndexExclusive) {
+ @SuppressWarnings("unchecked")
+ public static <T> T[] subarray(T[] array, int startIndexInclusive, int endIndexExclusive) {
if (array == null) {
return null;
}
@@ -451,9 +453,9 @@
int newSize = endIndexExclusive - startIndexInclusive;
Class<?> type = array.getClass().getComponentType();
if (newSize <= 0) {
- return (Object[]) Array.newInstance(type, 0);
+ return (T[]) Array.newInstance(type, 0);
}
- Object[] subarray = (Object[]) Array.newInstance(type, newSize);
+ T[] subarray = (T[]) Array.newInstance(type, newSize);
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
@@ -777,12 +779,12 @@
* <code>null</code> arrays as length <code>0</code>.
*
* <p>Any multi-dimensional aspects of the arrays are ignored.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
* <code>null</code> as an empty array
- */
+ */
public static boolean isSameLength(Object[] array1, Object[] array2) {
if ((array1 == null && array2 != null && array2.length > 0) ||
(array2 == null && array1 != null && array1.length > 0) ||
@@ -795,7 +797,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -813,7 +815,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -831,7 +833,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -849,7 +851,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -867,7 +869,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -885,7 +887,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -903,7 +905,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -921,7 +923,7 @@
/**
* <p>Checks whether two arrays are the same length, treating
* <code>null</code> arrays as length <code>0</code>.</p>
- *
+ *
* @param array1 the first array, may be <code>null</code>
* @param array2 the second array, may be <code>null</code>
* @return <code>true</code> if length of arrays matches, treating
@@ -967,12 +969,12 @@
/**
* <p>Checks whether two arrays are the same type taking into account
* multi-dimensional arrays.</p>
- *
+ *
* @param array1 the first array, must not be <code>null</code>
* @param array2 the second array, must not be <code>null</code>
* @return <code>true</code> if type of arrays matches
* @throws IllegalArgumentException if either array is <code>null</code>
- */
+ */
public static boolean isSameType(Object array1, Object array2) {
if (array1 == null || array2 == null) {
throw new IllegalArgumentException("The Array must not be null");
@@ -982,13 +984,13 @@
// Reverse
//-----------------------------------------------------------------------
- /**
+ /**
* <p>Reverses the order of the given array.</p>
*
* <p>There is no special handling for multi-dimensional arrays.</p>
*
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(Object[] array) {
@@ -1009,9 +1011,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(long[] array) {
@@ -1032,9 +1034,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(int[] array) {
@@ -1055,9 +1057,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(short[] array) {
@@ -1078,9 +1080,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(char[] array) {
@@ -1101,9 +1103,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(byte[] array) {
@@ -1124,9 +1126,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(double[] array) {
@@ -1147,9 +1149,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(float[] array) {
@@ -1170,9 +1172,9 @@
/**
* <p>Reverses the order of the given array.</p>
- *
+ *
* <p>This method does nothing for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to reverse, may be <code>null</code>
*/
public static void reverse(boolean[] array) {
@@ -1193,17 +1195,17 @@
// IndexOf search
// ----------------------------------------------------------------------
-
+
// Object IndexOf
//-----------------------------------------------------------------------
/**
* <p>Finds the index of the given object in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param objectToFind the object to find, may be <code>null</code>
- * @return the index of the object within the array,
+ * @return the index of the object within the array,
* {@link #INDEX_NOT_FOUND} (<code>-1</code>) if not found or <code>null</code> array input
*/
public static int indexOf(Object[] array, Object objectToFind) {
@@ -1217,7 +1219,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param objectToFind the object to find, may be <code>null</code>
* @param startIndex the index to start searching at
@@ -1237,7 +1239,7 @@
return i;
}
}
- } else {
+ } else {//TODO add quick type compatibility check
for (int i = startIndex; i < array.length; i++) {
if (objectToFind.equals(array[i])) {
return i;
@@ -1251,7 +1253,7 @@
* <p>Finds the last index of the given object within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param objectToFind the object to find, may be <code>null</code>
* @return the last index of the object within the array,
@@ -1268,7 +1270,7 @@
*
* <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than
* the array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param objectToFind the object to find, may be <code>null</code>
* @param startIndex the start index to travers backwards from
@@ -1290,7 +1292,7 @@
return i;
}
}
- } else {
+ } else {//TODO as above
for (int i = startIndex; i >= 0; i--) {
if (objectToFind.equals(array[i])) {
return i;
@@ -1304,7 +1306,7 @@
* <p>Checks if the object is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param objectToFind the object to find
* @return <code>true</code> if the array contains the object
@@ -1319,7 +1321,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -1336,7 +1338,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -1362,7 +1364,7 @@
* <p>Finds the last index of the given value within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -1379,7 +1381,7 @@
*
* <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -1407,7 +1409,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -1422,7 +1424,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -1439,7 +1441,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -1465,7 +1467,7 @@
* <p>Finds the last index of the given value within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -1482,7 +1484,7 @@
*
* <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -1510,7 +1512,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -1525,7 +1527,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -1542,7 +1544,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -1568,7 +1570,7 @@
* <p>Finds the last index of the given value within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -1583,9 +1585,9 @@
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
*
- * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
+ * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -1613,7 +1615,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -1628,7 +1630,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -1646,7 +1648,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -1673,7 +1675,7 @@
* <p>Finds the last index of the given value within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -1691,7 +1693,7 @@
*
* <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -1720,7 +1722,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -1736,7 +1738,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -1753,7 +1755,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -1779,7 +1781,7 @@
* <p>Finds the last index of the given value within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -1794,9 +1796,9 @@
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
*
- * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
+ * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -1824,7 +1826,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -1839,7 +1841,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -1855,7 +1857,7 @@
* defined by valueToFind - tolerance and valueToFind + tolerance.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param tolerance tolerance of the search
@@ -1873,7 +1875,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -1904,7 +1906,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -1933,7 +1935,7 @@
* <p>Finds the last index of the given value within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -1949,7 +1951,7 @@
* defined by valueToFind - tolerance and valueToFind + tolerance.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param tolerance tolerance of the search
@@ -1965,9 +1967,9 @@
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
*
- * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
+ * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -1998,9 +2000,9 @@
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
*
- * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
+ * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -2031,7 +2033,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -2042,7 +2044,7 @@
/**
* <p>Checks if a value falling within the given tolerance is in the
- * given array. If the array contains a value within the inclusive range
+ * given array. If the array contains a value within the inclusive range
* defined by (value - tolerance) to (value + tolerance).</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array
@@ -2063,7 +2065,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -2080,7 +2082,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -2106,7 +2108,7 @@
* <p>Finds the last index of the given value within the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -2121,9 +2123,9 @@
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
*
- * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
+ * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than the
* array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -2151,7 +2153,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -2166,7 +2168,7 @@
* <p>Finds the index of the given value in the array.</p>
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @return the index of the value within the array,
@@ -2183,7 +2185,7 @@
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} (<code>-1</code>).</p>
- *
+ *
* @param array the array to search through for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the index to start searching at
@@ -2209,9 +2211,9 @@
/**
* <p>Finds the last index of the given value within the array.</p>
*
- * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) if
+ * <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) if
* <code>null</code> array input.</p>
- *
+ *
* @param array the array to travers backwords looking for the object, may be <code>null</code>
* @param valueToFind the object to find
* @return the last index of the value within the array,
@@ -2226,9 +2228,9 @@
*
* <p>This method returns {@link #INDEX_NOT_FOUND} (<code>-1</code>) for a <code>null</code> input array.</p>
*
- * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than
+ * <p>A negative startIndex will return {@link #INDEX_NOT_FOUND} (<code>-1</code>). A startIndex larger than
* the array length will search from the end of the array.</p>
- *
+ *
* @param array the array to traverse for looking for the object, may be <code>null</code>
* @param valueToFind the value to find
* @param startIndex the start index to travers backwards from
@@ -2256,7 +2258,7 @@
* <p>Checks if the value is in the given array.</p>
*
* <p>The method returns <code>false</code> if a <code>null</code> array is passed in.</p>
- *
+ *
* @param array the array to search through
* @param valueToFind the value to find
* @return <code>true</code> if the array contains the object
@@ -2274,7 +2276,7 @@
* <p>Converts an array of object Characters to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Character</code> array, may be <code>null</code>
* @return a <code>char</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2294,9 +2296,9 @@
/**
* <p>Converts an array of object Character to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Character</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return a <code>char</code> array, <code>null</code> if null array input
@@ -2314,12 +2316,12 @@
}
return result;
}
-
+
/**
* <p>Converts an array of primitive chars to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>char</code> array
* @return a <code>Character</code> array, <code>null</code> if null array input
*/
@@ -2331,18 +2333,18 @@
}
final Character[] result = new Character[array.length];
for (int i = 0; i < array.length; i++) {
- result[i] = new Character(array[i]);
+ result[i] = Character.valueOf(array[i]);
}
return result;
- }
-
+ }
+
// Long array converters
// ----------------------------------------------------------------------
/**
* <p>Converts an array of object Longs to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Long</code> array, may be <code>null</code>
* @return a <code>long</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2359,12 +2361,12 @@
}
return result;
}
-
+
/**
* <p>Converts an array of object Long to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Long</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return a <code>long</code> array, <code>null</code> if null array input
@@ -2382,12 +2384,12 @@
}
return result;
}
-
+
/**
* <p>Converts an array of primitive longs to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>long</code> array
* @return a <code>Long</code> array, <code>null</code> if null array input
*/
@@ -2399,7 +2401,7 @@
}
final Long[] result = new Long[array.length];
for (int i = 0; i < array.length; i++) {
- result[i] = new Long(array[i]);
+ result[i] = Long.valueOf(array[i]);
}
return result;
}
@@ -2410,7 +2412,7 @@
* <p>Converts an array of object Integers to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Integer</code> array, may be <code>null</code>
* @return an <code>int</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2430,9 +2432,9 @@
/**
* <p>Converts an array of object Integer to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Integer</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return an <code>int</code> array, <code>null</code> if null array input
@@ -2455,7 +2457,7 @@
* <p>Converts an array of primitive ints to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array an <code>int</code> array
* @return an <code>Integer</code> array, <code>null</code> if null array input
*/
@@ -2467,18 +2469,18 @@
}
final Integer[] result = new Integer[array.length];
for (int i = 0; i < array.length; i++) {
- result[i] = new Integer(array[i]);
+ result[i] = Integer.valueOf(array[i]);
}
return result;
}
-
+
// Short array converters
// ----------------------------------------------------------------------
/**
* <p>Converts an array of object Shorts to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Short</code> array, may be <code>null</code>
* @return a <code>byte</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2498,9 +2500,9 @@
/**
* <p>Converts an array of object Short to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Short</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return a <code>byte</code> array, <code>null</code> if null array input
@@ -2523,7 +2525,7 @@
* <p>Converts an array of primitive shorts to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>short</code> array
* @return a <code>Short</code> array, <code>null</code> if null array input
*/
@@ -2535,10 +2537,10 @@
}
final Short[] result = new Short[array.length];
for (int i = 0; i < array.length; i++) {
- result[i] = new Short(array[i]);
+ result[i] = Short.valueOf(array[i]);
}
return result;
- }
+ }
// Byte array converters
// ----------------------------------------------------------------------
@@ -2546,7 +2548,7 @@
* <p>Converts an array of object Bytes to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Byte</code> array, may be <code>null</code>
* @return a <code>byte</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2566,9 +2568,9 @@
/**
* <p>Converts an array of object Bytes to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Byte</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return a <code>byte</code> array, <code>null</code> if null array input
@@ -2591,7 +2593,7 @@
* <p>Converts an array of primitive bytes to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>byte</code> array
* @return a <code>Byte</code> array, <code>null</code> if null array input
*/
@@ -2606,15 +2608,15 @@
result[i] = Byte.valueOf(array[i]);
}
return result;
- }
-
+ }
+
// Double array converters
// ----------------------------------------------------------------------
/**
* <p>Converts an array of object Doubles to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Double</code> array, may be <code>null</code>
* @return a <code>double</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2634,9 +2636,9 @@
/**
* <p>Converts an array of object Doubles to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Double</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return a <code>double</code> array, <code>null</code> if null array input
@@ -2659,7 +2661,7 @@
* <p>Converts an array of primitive doubles to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>double</code> array
* @return a <code>Double</code> array, <code>null</code> if null array input
*/
@@ -2671,7 +2673,7 @@
}
final Double[] result = new Double[array.length];
for (int i = 0; i < array.length; i++) {
- result[i] = new Double(array[i]);
+ result[i] = Double.valueOf(array[i]);
}
return result;
}
@@ -2682,7 +2684,7 @@
* <p>Converts an array of object Floats to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Float</code> array, may be <code>null</code>
* @return a <code>float</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2702,9 +2704,9 @@
/**
* <p>Converts an array of object Floats to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Float</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return a <code>float</code> array, <code>null</code> if null array input
@@ -2727,7 +2729,7 @@
* <p>Converts an array of primitive floats to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>float</code> array
* @return a <code>Float</code> array, <code>null</code> if null array input
*/
@@ -2739,7 +2741,7 @@
}
final Float[] result = new Float[array.length];
for (int i = 0; i < array.length; i++) {
- result[i] = new Float(array[i]);
+ result[i] = Float.valueOf(array[i]);
}
return result;
}
@@ -2750,7 +2752,7 @@
* <p>Converts an array of object Booleans to primitives.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Boolean</code> array, may be <code>null</code>
* @return a <code>boolean</code> array, <code>null</code> if null array input
* @throws NullPointerException if array content is <code>null</code>
@@ -2770,9 +2772,9 @@
/**
* <p>Converts an array of object Booleans to primitives handling <code>null</code>.</p>
- *
+ *
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>Boolean</code> array, may be <code>null</code>
* @param valueForNull the value to insert if <code>null</code> found
* @return a <code>boolean</code> array, <code>null</code> if null array input
@@ -2795,7 +2797,7 @@
* <p>Converts an array of primitive booleans to objects.</p>
*
* <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
- *
+ *
* @param array a <code>boolean</code> array
* @return a <code>Boolean</code> array, <code>null</code> if null array input
*/
@@ -2956,11 +2958,15 @@
*
* @param array1 the first array whose elements are added to the new array, may be <code>null</code>
* @param array2 the second array whose elements are added to the new array, may be <code>null</code>
- * @return The new array, <code>null</code> if <code>null</code> array inputs.
+ * @return The new array, <code>null</code> if <code>null</code> array inputs.
* The type of the new array is the type of the first array.
* @since 2.1
*/
public static Object[] addAll(Object[] array1, Object[] array2) {
+ /* this method could be generic as <T, U extends T> T[] addAll(T[], U[]), but if array1 == null,
+ * clone array2, then caller tries to add T objects to the U clone, could be a problem.
+ * Could add another version of the method where the first array cannot be null... :/
+ */
if (array1 == null) {
return clone(array2);
} else if (array2 == null) {
@@ -3209,12 +3215,12 @@
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, null) = [null]
* ArrayUtils.add(null, "a") = ["a"]
@@ -3222,35 +3228,36 @@
* ArrayUtils.add(["a"], "b") = ["a", "b"]
* ArrayUtils.add(["a", "b"], "c") = ["a", "b", "c"]
* </pre>
- *
+ *
* @param array the array to "add" the element to, may be <code>null</code>
* @param element the object to add
* @return A new array containing the existing elements plus the new element
* @since 2.1
*/
- public static Object[] add(Object[] array, Object element) {
+ @SuppressWarnings("unchecked")
+ public static <T> T[] add(T[] array, T element) {
Class<?> type = array != null ? array.getClass() : (element != null ? element.getClass() : Object.class);
- Object[] newArray = (Object[]) copyArrayGrow1(array, type);
+ T[] newArray = (T[]) copyArrayGrow1(array, type);
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, true) = [true]
* ArrayUtils.add([true], false) = [true, false]
* ArrayUtils.add([true, false], true) = [true, false, true]
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3261,23 +3268,23 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0) = [0]
* ArrayUtils.add([1], 0) = [1, 0]
* ArrayUtils.add([1, 0], 1) = [1, 0, 1]
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3288,23 +3295,23 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, '0') = ['0']
* ArrayUtils.add(['1'], '0') = ['1', '0']
* ArrayUtils.add(['1', '0'], '1') = ['1', '0', '1']
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3315,23 +3322,23 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0) = [0]
* ArrayUtils.add([1], 0) = [1, 0]
* ArrayUtils.add([1, 0], 1) = [1, 0, 1]
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3342,23 +3349,23 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0) = [0]
* ArrayUtils.add([1], 0) = [1, 0]
* ArrayUtils.add([1, 0], 1) = [1, 0, 1]
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3369,23 +3376,23 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0) = [0]
* ArrayUtils.add([1], 0) = [1, 0]
* ArrayUtils.add([1, 0], 1) = [1, 0, 1]
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3396,23 +3403,23 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0) = [0]
* ArrayUtils.add([1], 0) = [1, 0]
* ArrayUtils.add([1, 0], 1) = [1, 0, 1]
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3423,23 +3430,23 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
* <p>Copies the given array and adds the given element at the end of the new array.</p>
*
* <p>The new array contains the same elements of the input
- * array plus the given element in the last position. The component type of
+ * array plus the given element in the last position. The component type of
* the new array is the same as that of the input array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0) = [0]
* ArrayUtils.add([1], 0) = [1, 0]
* ArrayUtils.add([1, 0], 1) = [1, 0, 1]
* </pre>
- *
+ *
* @param array the array to copy and add the element to, may be <code>null</code>
* @param element the object to add at the last index of the new array
* @return A new array containing the existing elements plus the new element
@@ -3450,16 +3457,16 @@
newArray[newArray.length - 1] = element;
return newArray;
}
-
+
/**
- * Returns a copy of the given array of size 1 greater than the argument.
+ * Returns a copy of the given array of size 1 greater than the argument.
* The last value of the array is left to the default value.
- *
+ *
* @param array The array to copy, must not be <code>null</code>.
- * @param newArrayComponentType If <code>array</code> is <code>null</code>, create a
+ * @param newArrayComponentType If <code>array</code> is <code>null</code>, create a
* size 1 array of this type.
* @return A new copy of the array of size 1 greater than the input.
- */
+ */
private static Object copyArrayGrow1(Object array, Class<?> newArrayComponentType) {
if (array != null) {
int arrayLength = Array.getLength(array);
@@ -3469,20 +3476,20 @@
}
return Array.newInstance(newArrayComponentType, 1);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0, null) = [null]
* ArrayUtils.add(null, 0, "a") = ["a"]
@@ -3490,70 +3497,71 @@
* ArrayUtils.add(["a"], 1, "b") = ["a", "b"]
* ArrayUtils.add(["a", "b"], 3, "c") = ["a", "b", "c"]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
- public static Object[] add(Object[] array, int index, Object element) {
+ @SuppressWarnings("unchecked")
+ public static <T> T[] add(T[] array, int index, T element) {
Class<?> clss = null;
if (array != null) {
clss = array.getClass().getComponentType();
} else if (element != null) {
clss = element.getClass();
} else {
- return new Object[]{null};
+ return (T[]) new Object[] { null };
}
- return (Object[]) add(array, index, element, clss);
+ return (T[]) add(array, index, element, clss);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0, true) = [true]
* ArrayUtils.add([true], 0, false) = [false, true]
* ArrayUtils.add([false], 1, true) = [false, true]
* ArrayUtils.add([true, false], 1, true) = [true, true, false]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static boolean[] add(boolean[] array, int index, boolean element) {
return (boolean[]) add(array, index, Boolean.valueOf(element), Boolean.TYPE);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add(null, 0, 'a') = ['a']
* ArrayUtils.add(['a'], 0, 'b') = ['b', 'a']
@@ -3561,207 +3569,207 @@
* ArrayUtils.add(['a', 'b'], 1, 'k') = ['a', 'k', 'b']
* ArrayUtils.add(['a', 'b', 'c'], 1, 't') = ['a', 't', 'b', 'c']
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static char[] add(char[] array, int index, char element) {
- return (char[]) add(array, index, new Character(element), Character.TYPE);
+ return (char[]) add(array, index, Character.valueOf(element), Character.TYPE);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add([1], 0, 2) = [2, 1]
* ArrayUtils.add([2, 6], 2, 3) = [2, 6, 3]
* ArrayUtils.add([2, 6], 0, 1) = [1, 2, 6]
* ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static byte[] add(byte[] array, int index, byte element) {
return (byte[]) add(array, index, Byte.valueOf(element), Byte.TYPE);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add([1], 0, 2) = [2, 1]
* ArrayUtils.add([2, 6], 2, 10) = [2, 6, 10]
* ArrayUtils.add([2, 6], 0, -4) = [-4, 2, 6]
* ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static short[] add(short[] array, int index, short element) {
- return (short[]) add(array, index, new Short(element), Short.TYPE);
+ return (short[]) add(array, index, Short.valueOf(element), Short.TYPE);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add([1], 0, 2) = [2, 1]
* ArrayUtils.add([2, 6], 2, 10) = [2, 6, 10]
* ArrayUtils.add([2, 6], 0, -4) = [-4, 2, 6]
* ArrayUtils.add([2, 6, 3], 2, 1) = [2, 6, 1, 3]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static int[] add(int[] array, int index, int element) {
- return (int[]) add(array, index, new Integer(element), Integer.TYPE);
+ return (int[]) add(array, index, Integer.valueOf(element), Integer.TYPE);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add([1L], 0, 2L) = [2L, 1L]
* ArrayUtils.add([2L, 6L], 2, 10L) = [2L, 6L, 10L]
* ArrayUtils.add([2L, 6L], 0, -4L) = [-4L, 2L, 6L]
* ArrayUtils.add([2L, 6L, 3L], 2, 1L) = [2L, 6L, 1L, 3L]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static long[] add(long[] array, int index, long element) {
- return (long[]) add(array, index, new Long(element), Long.TYPE);
+ return (long[]) add(array, index, Long.valueOf(element), Long.TYPE);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add([1.1f], 0, 2.2f) = [2.2f, 1.1f]
* ArrayUtils.add([2.3f, 6.4f], 2, 10.5f) = [2.3f, 6.4f, 10.5f]
* ArrayUtils.add([2.6f, 6.7f], 0, -4.8f) = [-4.8f, 2.6f, 6.7f]
* ArrayUtils.add([2.9f, 6.0f, 0.3f], 2, 1.0f) = [2.9f, 6.0f, 1.0f, 0.3f]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static float[] add(float[] array, int index, float element) {
- return (float[]) add(array, index, new Float(element), Float.TYPE);
+ return (float[]) add(array, index, Float.valueOf(element), Float.TYPE);
}
-
+
/**
- * <p>Inserts the specified element at the specified position in the array.
+ * <p>Inserts the specified element at the specified position in the array.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array plus the given element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array plus the given element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, a new one element array is returned
* whose component type is the same as the element.</p>
- *
+ *
* <pre>
* ArrayUtils.add([1.1], 0, 2.2) = [2.2, 1.1]
* ArrayUtils.add([2.3, 6.4], 2, 10.5) = [2.3, 6.4, 10.5]
* ArrayUtils.add([2.6, 6.7], 0, -4.8) = [-4.8, 2.6, 6.7]
* ArrayUtils.add([2.9, 6.0, 0.3], 2, 1.0) = [2.9, 6.0, 1.0, 0.3]
* </pre>
- *
+ *
* @param array the array to add the element to, may be <code>null</code>
* @param index the position of the new object
* @param element the object to add
* @return A new array containing the existing elements and the new element
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index > array.length).
*/
public static double[] add(double[] array, int index, double element) {
- return (double[]) add(array, index, new Double(element), Double.TYPE);
+ return (double[]) add(array, index, Double.valueOf(element), Double.TYPE);
}
-
+
/**
- * Underlying implementation of add(array, index, element) methods.
- * The last parameter is the class, which may not equal element.getClass
+ * Underlying implementation of add(array, index, element) methods.
+ * The last parameter is the class, which may not equal element.getClass
* for primitives.
*
* @param array the array to add the element to, may be <code>null</code>
@@ -3791,15 +3799,15 @@
}
return result;
}
-
+
/**
* <p>Removes the element at the specified position from the specified array.
* All subsequent elements are shifted to the left (substracts one from
* their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array except the element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array except the element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, an IndexOutOfBoundsException
@@ -3811,28 +3819,29 @@
* ArrayUtils.remove(["a", "b"], 1) = ["a"]
* ArrayUtils.remove(["a", "b", "c"], 1) = ["a", "c"]
* </pre>
- *
+ *
* @param array the array to remove the element from, may not be <code>null</code>
* @param index the position of the element to be removed
* @return A new array containing the existing elements except the element
* at the specified position.
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index >= array.length), or if the array is <code>null</code>.
* @since 2.1
*/
- public static Object[] remove(Object[] array, int index) {
- return (Object[]) remove((Object) array, index);
+ @SuppressWarnings("unchecked")
+ public static <T> T[] remove(T[] array, int index) {
+ return (T[]) remove((Object) array, index);
}
-
+
/**
* <p>Removes the first occurrence of the specified element from the
- * specified array. All subsequent elements are shifted to the left
+ * specified array. All subsequent elements are shifted to the left
* (substracts one from their indices). If the array doesn't contains
* such an element, no elements are removed from the array.</p>
*
* <p>This method returns a new array with the same elements of the input
- * array except the first occurrence of the specified element. The component
- * type of the returned array is always the same as that of the input
+ * array except the first occurrence of the specified element. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <pre>
@@ -3842,29 +3851,29 @@
* ArrayUtils.removeElement(["a", "b"], "a") = ["b"]
* ArrayUtils.removeElement(["a", "b", "a"], "a") = ["b", "a"]
* </pre>
- *
+ *
* @param array the array to remove the element from, may be <code>null</code>
* @param element the element to be removed
* @return A new array containing the existing elements except the first
* occurrence of the specified element.
* @since 2.1
*/
- public static Object[] removeElement(Object[] array, Object element) {
+ public static <T> T[] removeElement(T[] array, Object element) {
int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
- }
+ }
return remove(array, index);
}
-
+
/**
* <p>Removes the element at the specified position from the specified array.
* All subsequent elements are shifted to the left (substracts one from
* their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array except the element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array except the element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, an IndexOutOfBoundsException
@@ -3876,28 +3885,28 @@
* ArrayUtils.remove([true, false], 1) = [true]
* ArrayUtils.remove([true, true, false], 1) = [true, false]
* </pre>
- *
+ *
* @param array the array to remove the element from, may not be <code>null</code>
* @param index the position of the element to be removed
* @return A new array containing the existing elements except the element
* at the specified position.
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index >= array.length), or if the array is <code>null</code>.
* @since 2.1
*/
public static boolean[] remove(boolean[] array, int index) {
return (boolean[]) remove((Object) array, index);
}
-
+
/**
* <p>Removes the first occurrence of the specified element from the
- * specified array. All subsequent elements are shifted to the left
+ * specified array. All subsequent elements are shifted to the left
* (substracts one from their indices). If the array doesn't contains
* such an element, no elements are removed from the array.</p>
*
* <p>This method returns a new array with the same elements of the input
- * array except the first occurrence of the specified element. The component
- * type of the returned array is always the same as that of the input
+ * array except the first occurrence of the specified element. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <pre>
@@ -3907,7 +3916,7 @@
* ArrayUtils.removeElement([true, false], false) = [true]
* ArrayUtils.removeElement([true, false, true], true) = [false, true]
* </pre>
- *
+ *
* @param array the array to remove the element from, may be <code>null</code>
* @param element the element to be removed
* @return A new array containing the existing elements except the first
@@ -3918,18 +3927,18 @@
int index = indexOf(array, element);
if (index == INDEX_NOT_FOUND) {
return clone(array);
- }
+ }
return remove(array, index);
}
-
+
/**
* <p>Removes the element at the specified position from the specified array.
* All subsequent elements are shifted to the left (substracts one from
* their indices).</p>
*
* <p>This method returns a new array with the same elements of the input
- * array except the element on the specified position. The component
- * type of the returned array is always the same as that of the input
+ * array except the element on the specified position. The component
+ * type of the returned array is always the same as that of the input
* array.</p>
*
* <p>If the input array is <code>null</code>, an IndexOutOfBoundsException
@@ -3941,28 +3950,28 @@
* ArrayUtils.remove([1, 0], 1) = [1]
* ArrayUtils.remove([1, 0, 1], 1) = [1, 1]
* </pre>
- *
+ *
* @param array the array to remove the element from, may not be <code>null</code>
* @param index the position of the element to be removed
* @return A new array containing the existing elements except the element
* at the specified position.
- * @throws IndexOutOfBoundsException if the index is out of range
+ * @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index >= array.length), or if the array is <code>null</code>.
* @since 2.1
*/
public static byte[] remove(byte[] array, int index) {
return (byte[]) remove((Object) array, index);
}
-
+
/**
* <p>Removes the first occurrence of the specified element from the
- * specified array. All subsequent elements are shifted to the left
+ * specified array. All subsequent elements are shifted to the left
* (substracts one from their indices). If the array doesn't contains
* such an element, no elements are removed from the array.</p>
*
[... 471 lines stripped ...]