Class ArrayUtilities


  • public final class ArrayUtilities
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ArrayUtilities()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean[] append​(boolean[] array, boolean value)  
      static boolean[] append​(boolean[] array, boolean... values)  
      static byte[] append​(byte[] array, byte value)  
      static byte[] append​(byte[] array, byte... values)  
      static char[] append​(char[] array, char value)  
      static char[] append​(char[] array, char... values)  
      static double[] append​(double[] array, double value)  
      static double[] append​(double[] array, double... values)  
      static float[] append​(float[] array, float value)  
      static float[] append​(float[] array, float... values)  
      static int[] append​(int[] array, int value)  
      static int[] append​(int[] array, int... values)  
      static long[] append​(long[] array, long value)  
      static long[] append​(long[] array, long... values)  
      static short[] append​(short[] array, short value)  
      static short[] append​(short[] array, short... values)  
      static <T> T[] append​(T[] array, T value)  
      static <T> T[] append​(T[] array, T... values)  
      static <T> java.util.List<T> asUnmodifiableList​(T... items)  
      static boolean contains​(boolean[] array, boolean value)  
      static boolean contains​(byte[] array, byte value)  
      static boolean contains​(char[] array, char value)  
      static boolean contains​(double[] array, double value)  
      static boolean contains​(float[] array, float value)  
      static boolean contains​(int[] array, int value)  
      static boolean contains​(long[] array, long value)  
      static boolean contains​(short[] array, short value)  
      static <T> boolean contains​(T[] array, T value)  
      static boolean[] copy​(boolean[] source, boolean[] target)  
      static boolean[] copy​(boolean[] source, int offset, boolean[] target, int targetOffset, int length)  
      static byte[] copy​(byte[] source, byte[] target)  
      static byte[] copy​(byte[] source, int offset, byte[] target, int targetOffset, int length)  
      static char[] copy​(char[] source, char[] target)  
      static char[] copy​(char[] source, int offset, char[] target, int targetOffset, int length)  
      static double[] copy​(double[] source, double[] target)  
      static double[] copy​(double[] source, int offset, double[] target, int targetOffset, int length)  
      static float[] copy​(float[] source, float[] target)  
      static float[] copy​(float[] source, int offset, float[] target, int targetOffset, int length)  
      static int[] copy​(int[] source, int[] target)  
      static int[] copy​(int[] source, int offset, int[] target, int targetOffset, int length)  
      static long[] copy​(long[] source, int offset, long[] target, int targetOffset, int length)  
      static long[] copy​(long[] source, long[] target)  
      static short[] copy​(short[] source, int offset, short[] target, int targetOffset, int length)  
      static short[] copy​(short[] source, short[] target)  
      static <T> T[] copy​(T[] source, int offset, T[] target, int targetOffset, int length)  
      static <T> T[] copy​(T[] source, T[] target)  
      static java.lang.Object copyOf​(java.lang.Object array, int newLength)  
      static java.lang.Object copyOf​(java.lang.Object array, int newLength, java.lang.Class<?> newType)  
      static java.lang.Object copyOfRange​(java.lang.Object array, int from, int to)  
      static java.lang.Object copyOfRange​(java.lang.Object array, int from, int to, java.lang.Class<?> newType)  
      static <T> T[] create​(java.lang.Class<T> elementType, int length)  
      static java.lang.Object createAny​(java.lang.Class<?> elementType, int length)  
      static int indexOf​(boolean[] array, boolean value)  
      static int indexOf​(byte[] array, byte value)  
      static int indexOf​(char[] array, char value)  
      static int indexOf​(double[] array, double value)  
      static int indexOf​(float[] array, float value)  
      static int indexOf​(int[] array, int value)  
      static int indexOf​(long[] array, long value)  
      static int indexOf​(short[] array, short value)  
      static <T> int indexOf​(T[] array, T value)  
      static boolean[] insert​(boolean[] array, int index, boolean value)  
      static boolean[] insert​(boolean[] array, int index, boolean... values)  
      static byte[] insert​(byte[] array, int index, byte value)  
      static byte[] insert​(byte[] array, int index, byte... values)  
      static char[] insert​(char[] array, int index, char value)  
      static char[] insert​(char[] array, int index, char... values)  
      static double[] insert​(double[] array, int index, double value)  
      static double[] insert​(double[] array, int index, double... values)  
      static float[] insert​(float[] array, int index, float value)  
      static float[] insert​(float[] array, int index, float... values)  
      static int[] insert​(int[] array, int index, int value)  
      static int[] insert​(int[] array, int index, int... values)  
      static long[] insert​(long[] array, int index, long value)  
      static long[] insert​(long[] array, int index, long... values)  
      static short[] insert​(short[] array, int index, short value)  
      static short[] insert​(short[] array, int index, short... values)  
      static <T> T[] insert​(T[] array, int index, T value)  
      static <T> T[] insert​(T[] array, int index, T... values)  
      static boolean isArray​(java.lang.Object value)  
      static boolean isNullOrEmpty​(boolean[] array)  
      static boolean isNullOrEmpty​(byte[] array)  
      static boolean isNullOrEmpty​(char[] array)  
      static boolean isNullOrEmpty​(double[] array)  
      static boolean isNullOrEmpty​(float[] array)  
      static boolean isNullOrEmpty​(int[] array)  
      static boolean isNullOrEmpty​(long[] array)  
      static boolean isNullOrEmpty​(short[] array)  
      static <T> boolean isNullOrEmpty​(T[] array)  
      static int lastIndexOf​(boolean[] array, boolean value)  
      static int lastIndexOf​(byte[] array, byte value)  
      static int lastIndexOf​(char[] array, char value)  
      static int lastIndexOf​(double[] array, double value)  
      static int lastIndexOf​(float[] array, float value)  
      static int lastIndexOf​(int[] array, int value)  
      static int lastIndexOf​(long[] array, long value)  
      static int lastIndexOf​(short[] array, short value)  
      static <T> int lastIndexOf​(T[] array, T value)  
      static <T> java.lang.Class<T[]> makeArrayType​(java.lang.Class<T> elementType)  
      static boolean[] prepend​(boolean[] array, boolean value)  
      static boolean[] prepend​(boolean[] array, boolean... values)  
      static byte[] prepend​(byte[] array, byte value)  
      static byte[] prepend​(byte[] array, byte... values)  
      static char[] prepend​(char[] array, char value)  
      static char[] prepend​(char[] array, char... values)  
      static double[] prepend​(double[] array, double value)  
      static double[] prepend​(double[] array, double... values)  
      static float[] prepend​(float[] array, float value)  
      static float[] prepend​(float[] array, float... values)  
      static int[] prepend​(int[] array, int value)  
      static int[] prepend​(int[] array, int... values)  
      static long[] prepend​(long[] array, long value)  
      static long[] prepend​(long[] array, long... values)  
      static short[] prepend​(short[] array, short value)  
      static short[] prepend​(short[] array, short... values)  
      static <T> T[] prepend​(T[] array, T value)  
      static <T> T[] prepend​(T[] array, T... values)  
      static int[] range​(int start, int count)  
      static boolean rangeEquals​(boolean[] first, boolean[] second, int offset, int length)  
      static boolean rangeEquals​(byte[] first, byte[] second, int offset, int length)  
      static boolean rangeEquals​(char[] first, char[] second, int offset, int length)  
      static boolean rangeEquals​(double[] first, double[] second, int offset, int length)  
      static boolean rangeEquals​(float[] first, float[] second, int offset, int length)  
      static boolean rangeEquals​(int[] first, int[] second, int offset, int length)  
      static boolean rangeEquals​(long[] first, long[] second, int offset, int length)  
      static boolean rangeEquals​(short[] first, short[] second, int offset, int length)  
      static <T> boolean rangeEquals​(T[] first, T[] second, int offset, int length)  
      static boolean[] remove​(boolean[] array, int index)  
      static byte[] remove​(byte[] array, int index)  
      static char[] remove​(char[] array, int index)  
      static double[] remove​(double[] array, int index)  
      static float[] remove​(float[] array, int index)  
      static int[] remove​(int[] array, int index)  
      static long[] remove​(long[] array, int index)  
      static short[] remove​(short[] array, int index)  
      static <T> T[] remove​(T[] array, int index)  
      static <T> T[] removeAll​(T[] array, T... values)  
      static <T> T[] removeFirst​(T[] array, T value)  
      static <T> T[] removeLast​(T[] array, T value)  
      static <T> T[] retainAll​(T[] array, T... values)  
      static <T> T[] union​(T[] array, T... values)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • GLOBAL_ARRAY_TYPE_CACHE

        private static final Cache<java.lang.Class<?>,​java.lang.Class<?>> GLOBAL_ARRAY_TYPE_CACHE
      • ARRAY_TYPE_CACHE

        private static final Cache<java.lang.Class<?>,​java.lang.Class<?>> ARRAY_TYPE_CACHE
    • Constructor Detail

      • ArrayUtilities

        private ArrayUtilities()
    • Method Detail

      • isArray

        public static boolean isArray​(java.lang.Object value)
      • create

        public static <T> T[] create​(java.lang.Class<T> elementType,
                                     int length)
      • createAny

        public static java.lang.Object createAny​(java.lang.Class<?> elementType,
                                                 int length)
      • range

        public static int[] range​(int start,
                                  int count)
      • copyOf

        public static java.lang.Object copyOf​(java.lang.Object array,
                                              int newLength)
      • copyOf

        public static java.lang.Object copyOf​(java.lang.Object array,
                                              int newLength,
                                              java.lang.Class<?> newType)
      • copyOfRange

        public static java.lang.Object copyOfRange​(java.lang.Object array,
                                                   int from,
                                                   int to)
      • copyOfRange

        public static java.lang.Object copyOfRange​(java.lang.Object array,
                                                   int from,
                                                   int to,
                                                   java.lang.Class<?> newType)
      • makeArrayType

        public static <T> java.lang.Class<T[]> makeArrayType​(java.lang.Class<T> elementType)
      • copy

        public static <T> T[] copy​(T[] source,
                                   T[] target)
      • copy

        public static <T> T[] copy​(T[] source,
                                   int offset,
                                   T[] target,
                                   int targetOffset,
                                   int length)
      • rangeEquals

        public static <T> boolean rangeEquals​(T[] first,
                                              T[] second,
                                              int offset,
                                              int length)
      • contains

        public static <T> boolean contains​(T[] array,
                                           T value)
      • indexOf

        public static <T> int indexOf​(T[] array,
                                      T value)
      • lastIndexOf

        public static <T> int lastIndexOf​(T[] array,
                                          T value)
      • insert

        public static <T> T[] insert​(T[] array,
                                     int index,
                                     T value)
      • insert

        @SafeVarargs
        public static <T> T[] insert​(T[] array,
                                     int index,
                                     T... values)
      • append

        public static <T> T[] append​(T[] array,
                                     T value)
      • append

        @SafeVarargs
        public static <T> T[] append​(T[] array,
                                     T... values)
      • prepend

        public static <T> T[] prepend​(T[] array,
                                      T value)
      • prepend

        @SafeVarargs
        public static <T> T[] prepend​(T[] array,
                                      T... values)
      • remove

        public static <T> T[] remove​(T[] array,
                                     int index)
      • isNullOrEmpty

        public static <T> boolean isNullOrEmpty​(T[] array)
      • removeAll

        @SafeVarargs
        public static <T> T[] removeAll​(T[] array,
                                        T... values)
      • removeFirst

        public static <T> T[] removeFirst​(T[] array,
                                          T value)
      • removeLast

        public static <T> T[] removeLast​(T[] array,
                                         T value)
      • retainAll

        @SafeVarargs
        public static <T> T[] retainAll​(T[] array,
                                        T... values)
      • union

        @SafeVarargs
        public static <T> T[] union​(T[] array,
                                    T... values)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(boolean[] array)
      • copy

        public static boolean[] copy​(boolean[] source,
                                     boolean[] target)
      • copy

        public static boolean[] copy​(boolean[] source,
                                     int offset,
                                     boolean[] target,
                                     int targetOffset,
                                     int length)
      • rangeEquals

        public static boolean rangeEquals​(boolean[] first,
                                          boolean[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(boolean[] array,
                                       boolean value)
      • indexOf

        public static int indexOf​(boolean[] array,
                                  boolean value)
      • lastIndexOf

        public static int lastIndexOf​(boolean[] array,
                                      boolean value)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(char[] array)
      • copy

        public static char[] copy​(char[] source,
                                  char[] target)
      • copy

        public static char[] copy​(char[] source,
                                  int offset,
                                  char[] target,
                                  int targetOffset,
                                  int length)
      • rangeEquals

        public static boolean rangeEquals​(char[] first,
                                          char[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(char[] array,
                                       char value)
      • indexOf

        public static int indexOf​(char[] array,
                                  char value)
      • lastIndexOf

        public static int lastIndexOf​(char[] array,
                                      char value)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(byte[] array)
      • copy

        public static byte[] copy​(byte[] source,
                                  byte[] target)
      • copy

        public static byte[] copy​(byte[] source,
                                  int offset,
                                  byte[] target,
                                  int targetOffset,
                                  int length)
      • rangeEquals

        public static boolean rangeEquals​(byte[] first,
                                          byte[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(byte[] array,
                                       byte value)
      • indexOf

        public static int indexOf​(byte[] array,
                                  byte value)
      • lastIndexOf

        public static int lastIndexOf​(byte[] array,
                                      byte value)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(short[] array)
      • copy

        public static short[] copy​(short[] source,
                                   short[] target)
      • copy

        public static short[] copy​(short[] source,
                                   int offset,
                                   short[] target,
                                   int targetOffset,
                                   int length)
      • rangeEquals

        public static boolean rangeEquals​(short[] first,
                                          short[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(short[] array,
                                       short value)
      • indexOf

        public static int indexOf​(short[] array,
                                  short value)
      • lastIndexOf

        public static int lastIndexOf​(short[] array,
                                      short value)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(int[] array)
      • copy

        public static int[] copy​(int[] source,
                                 int[] target)
      • copy

        public static int[] copy​(int[] source,
                                 int offset,
                                 int[] target,
                                 int targetOffset,
                                 int length)
      • rangeEquals

        public static boolean rangeEquals​(int[] first,
                                          int[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(int[] array,
                                       int value)
      • indexOf

        public static int indexOf​(int[] array,
                                  int value)
      • lastIndexOf

        public static int lastIndexOf​(int[] array,
                                      int value)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(long[] array)
      • copy

        public static long[] copy​(long[] source,
                                  long[] target)
      • copy

        public static long[] copy​(long[] source,
                                  int offset,
                                  long[] target,
                                  int targetOffset,
                                  int length)
      • rangeEquals

        public static boolean rangeEquals​(long[] first,
                                          long[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(long[] array,
                                       long value)
      • indexOf

        public static int indexOf​(long[] array,
                                  long value)
      • lastIndexOf

        public static int lastIndexOf​(long[] array,
                                      long value)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(float[] array)
      • copy

        public static float[] copy​(float[] source,
                                   float[] target)
      • copy

        public static float[] copy​(float[] source,
                                   int offset,
                                   float[] target,
                                   int targetOffset,
                                   int length)
      • rangeEquals

        public static boolean rangeEquals​(float[] first,
                                          float[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(float[] array,
                                       float value)
      • indexOf

        public static int indexOf​(float[] array,
                                  float value)
      • lastIndexOf

        public static int lastIndexOf​(float[] array,
                                      float value)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(double[] array)
      • copy

        public static double[] copy​(double[] source,
                                    double[] target)
      • copy

        public static double[] copy​(double[] source,
                                    int offset,
                                    double[] target,
                                    int targetOffset,
                                    int length)
      • rangeEquals

        public static boolean rangeEquals​(double[] first,
                                          double[] second,
                                          int offset,
                                          int length)
      • contains

        public static boolean contains​(double[] array,
                                       double value)
      • indexOf

        public static int indexOf​(double[] array,
                                  double value)
      • lastIndexOf

        public static int lastIndexOf​(double[] array,
                                      double value)
      • append

        public static boolean[] append​(boolean[] array,
                                       boolean value)
      • append

        public static boolean[] append​(boolean[] array,
                                       boolean... values)
      • prepend

        public static boolean[] prepend​(boolean[] array,
                                        boolean value)
      • prepend

        public static boolean[] prepend​(boolean[] array,
                                        boolean... values)
      • remove

        public static boolean[] remove​(boolean[] array,
                                       int index)
      • insert

        public static boolean[] insert​(boolean[] array,
                                       int index,
                                       boolean value)
      • insert

        public static boolean[] insert​(boolean[] array,
                                       int index,
                                       boolean... values)
      • append

        public static char[] append​(char[] array,
                                    char value)
      • append

        public static char[] append​(char[] array,
                                    char... values)
      • prepend

        public static char[] prepend​(char[] array,
                                     char value)
      • prepend

        public static char[] prepend​(char[] array,
                                     char... values)
      • remove

        public static char[] remove​(char[] array,
                                    int index)
      • insert

        public static char[] insert​(char[] array,
                                    int index,
                                    char value)
      • insert

        public static char[] insert​(char[] array,
                                    int index,
                                    char... values)
      • append

        public static byte[] append​(byte[] array,
                                    byte value)
      • append

        public static byte[] append​(byte[] array,
                                    byte... values)
      • prepend

        public static byte[] prepend​(byte[] array,
                                     byte value)
      • prepend

        public static byte[] prepend​(byte[] array,
                                     byte... values)
      • remove

        public static byte[] remove​(byte[] array,
                                    int index)
      • insert

        public static byte[] insert​(byte[] array,
                                    int index,
                                    byte value)
      • insert

        public static byte[] insert​(byte[] array,
                                    int index,
                                    byte... values)
      • append

        public static short[] append​(short[] array,
                                     short value)
      • append

        public static short[] append​(short[] array,
                                     short... values)
      • prepend

        public static short[] prepend​(short[] array,
                                      short value)
      • prepend

        public static short[] prepend​(short[] array,
                                      short... values)
      • remove

        public static short[] remove​(short[] array,
                                     int index)
      • insert

        public static short[] insert​(short[] array,
                                     int index,
                                     short value)
      • insert

        public static short[] insert​(short[] array,
                                     int index,
                                     short... values)
      • append

        public static int[] append​(int[] array,
                                   int value)
      • append

        public static int[] append​(int[] array,
                                   int... values)
      • prepend

        public static int[] prepend​(int[] array,
                                    int value)
      • prepend

        public static int[] prepend​(int[] array,
                                    int... values)
      • remove

        public static int[] remove​(int[] array,
                                   int index)
      • insert

        public static int[] insert​(int[] array,
                                   int index,
                                   int value)
      • insert

        public static int[] insert​(int[] array,
                                   int index,
                                   int... values)
      • append

        public static long[] append​(long[] array,
                                    long value)
      • append

        public static long[] append​(long[] array,
                                    long... values)
      • prepend

        public static long[] prepend​(long[] array,
                                     long value)
      • prepend

        public static long[] prepend​(long[] array,
                                     long... values)
      • remove

        public static long[] remove​(long[] array,
                                    int index)
      • insert

        public static long[] insert​(long[] array,
                                    int index,
                                    long value)
      • insert

        public static long[] insert​(long[] array,
                                    int index,
                                    long... values)
      • append

        public static float[] append​(float[] array,
                                     float value)
      • append

        public static float[] append​(float[] array,
                                     float... values)
      • prepend

        public static float[] prepend​(float[] array,
                                      float value)
      • prepend

        public static float[] prepend​(float[] array,
                                      float... values)
      • remove

        public static float[] remove​(float[] array,
                                     int index)
      • insert

        public static float[] insert​(float[] array,
                                     int index,
                                     float value)
      • insert

        public static float[] insert​(float[] array,
                                     int index,
                                     float... values)
      • append

        public static double[] append​(double[] array,
                                      double value)
      • append

        public static double[] append​(double[] array,
                                      double... values)
      • prepend

        public static double[] prepend​(double[] array,
                                       double value)
      • prepend

        public static double[] prepend​(double[] array,
                                       double... values)
      • remove

        public static double[] remove​(double[] array,
                                      int index)
      • insert

        public static double[] insert​(double[] array,
                                      int index,
                                      double value)
      • insert

        public static double[] insert​(double[] array,
                                      int index,
                                      double... values)
      • asUnmodifiableList

        @SafeVarargs
        public static <T> java.util.List<T> asUnmodifiableList​(T... items)