Class Arrays
- java.lang.Object
-
- cern.colt.Arrays
-
-
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 tominCapacity
elements.static byte[]
ensureCapacity(byte[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static char[]
ensureCapacity(char[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static double[]
ensureCapacity(double[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static float[]
ensureCapacity(float[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static int[]
ensureCapacity(int[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static long[]
ensureCapacity(long[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static short[]
ensureCapacity(short[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static Object[]
ensureCapacity(Object[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
elements.static String
toString(boolean[] array)
Returns a string representation of the specified array.static String
toString(byte[] array)
Returns a string representation of the specified array.static String
toString(char[] array)
Returns a string representation of the specified array.static String
toString(double[] array)
Returns a string representation of the specified array.static String
toString(float[] array)
Returns a string representation of the specified array.static String
toString(int[] array)
Returns a string representation of the specified array.static String
toString(long[] array)
Returns a string representation of the specified array.static String
toString(short[] array)
Returns a string representation of the specified array.static String
toString(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 thanmaxCapacity
elements.static byte[]
trimToCapacity(byte[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.static char[]
trimToCapacity(char[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.static double[]
trimToCapacity(double[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.static float[]
trimToCapacity(float[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.static int[]
trimToCapacity(int[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.static long[]
trimToCapacity(long[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.static short[]
trimToCapacity(short[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.static Object[]
trimToCapacity(Object[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
elements.
-
-
-
Method Detail
-
ensureCapacity
public static byte[] ensureCapacity(byte[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
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 tominCapacity
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 tominCapacity
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 tominCapacity
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 tominCapacity
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 tominCapacity
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 Object[] ensureCapacity(Object[] array, int minCapacity)
Ensures that a given array can hold up tominCapacity
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 tominCapacity
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 tominCapacity
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 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 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 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 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 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 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 String toString(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 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 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 thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static char[] trimToCapacity(char[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static double[] trimToCapacity(double[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static float[] trimToCapacity(float[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static int[] trimToCapacity(int[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static long[] trimToCapacity(long[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static Object[] trimToCapacity(Object[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static short[] trimToCapacity(short[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
trimToCapacity
public static boolean[] trimToCapacity(boolean[] array, int maxCapacity)
Ensures that the specified array cannot hold more thanmaxCapacity
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 ofmaxCapacity
containing the firstmaxCapacity
elements ofarray
.- Parameters:
maxCapacity
- the desired maximum capacity.
-
-