Package cern.colt

Class Arrays

java.lang.Object
cern.colt.Arrays

public class Arrays
extends Object
Array manipulations; complements java.util.Arrays.
Version:
1.0, 03-Jul-99
Author:
wolfgang.hoschek@cern.ch
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

    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 Object[] ensureCapacity​(Object[] array, int minCapacity)
    Ensures that a given array can hold up to minCapacity 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 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 Object[] trimToCapacity​(Object[] array, int maxCapacity)
    Ensures that the specified array cannot hold more than maxCapacity elements.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Arrays

      protected Arrays()
      Makes this class non instantiable, but still let's others inherit from it.
  • Method Details

    • 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 Object[] ensureCapacity​(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 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 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 Object[] trimToCapacity​(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.