Class Arrays
- java.lang.Object
-
- cern.colt.Arrays
-
public class Arrays extends java.lang.Object
Array manipulations; complements java.util.Arrays.- Version:
- 1.0, 03-Jul-99
- See Also:
Arrays
,Sorting
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Arrays()
Makes this class non instantiable, but still let's others inherit from it.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean[]
ensureCapacity(boolean[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static byte[]
ensureCapacity(byte[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static char[]
ensureCapacity(char[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static double[]
ensureCapacity(double[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static float[]
ensureCapacity(float[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static int[]
ensureCapacity(int[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static long[]
ensureCapacity(long[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static short[]
ensureCapacity(short[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static java.lang.Object[]
ensureCapacity(java.lang.Object[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements.static java.lang.String
toString(boolean[] array)
Returns a string representation of the specified array.static java.lang.String
toString(byte[] array)
Returns a string representation of the specified array.static java.lang.String
toString(char[] array)
Returns a string representation of the specified array.static java.lang.String
toString(double[] array)
Returns a string representation of the specified array.static java.lang.String
toString(float[] array)
Returns a string representation of the specified array.static java.lang.String
toString(int[] array)
Returns a string representation of the specified array.static java.lang.String
toString(long[] array)
Returns a string representation of the specified array.static java.lang.String
toString(short[] array)
Returns a string representation of the specified array.static java.lang.String
toString(java.lang.Object[] array)
Returns a string representation of the specified array.static boolean[]
trimToCapacity(boolean[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static byte[]
trimToCapacity(byte[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static char[]
trimToCapacity(char[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static double[]
trimToCapacity(double[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static float[]
trimToCapacity(float[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static int[]
trimToCapacity(int[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static long[]
trimToCapacity(long[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static short[]
trimToCapacity(short[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.static java.lang.Object[]
trimToCapacity(java.lang.Object[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements.
-
-
-
Method Detail
-
ensureCapacity
public static byte[] ensureCapacity(byte[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static char[] ensureCapacity(char[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static double[] ensureCapacity(double[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static float[] ensureCapacity(float[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static int[] ensureCapacity(int[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static long[] ensureCapacity(long[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static java.lang.Object[] ensureCapacity(java.lang.Object[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static short[] ensureCapacity(short[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
ensureCapacity
public static boolean[] ensureCapacity(boolean[] array, int minCapacity)
Ensures that a given array can hold up to minCapacity elements. Returns the identical array if it can hold at least the number of elements specified. Otherwise, returns a new array with increased capacity containing the same elements, ensuring that it can hold at least the number of elements specified by the minimum capacity argument.- Parameters:
minCapacity
- the desired minimum capacity.
-
toString
public static java.lang.String toString(byte[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(char[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(double[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(float[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(int[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(long[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(java.lang.Object[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(short[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
toString
public static java.lang.String toString(boolean[] array)
Returns a string representation of the specified array. The string representation consists of a list of the arrays's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space).- Returns:
- a string representation of the specified array.
-
trimToCapacity
public static byte[] trimToCapacity(byte[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static char[] trimToCapacity(char[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static double[] trimToCapacity(double[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static float[] trimToCapacity(float[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static int[] trimToCapacity(int[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static long[] trimToCapacity(long[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static java.lang.Object[] trimToCapacity(java.lang.Object[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static short[] trimToCapacity(short[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static boolean[] trimToCapacity(boolean[] array, int maxCapacity)
Ensures that the specified array cannot hold more than maxCapacity elements. An application can use this operation to minimize array storage.Returns the identical array if array.length <= maxCapacity. Otherwise, returns a new array with a length of maxCapacity containing the first maxCapacity elements of array.
- Parameters:
maxCapacity
- the desired maximum capacity.
-
-