Package jmri.util

Class ArrayUtil


  • public final class ArrayUtil
    extends java.lang.Object
    Useful array methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      ArrayUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean[] reverse​(boolean[] elements)
      Reverse an array of booleans.
      static double[] reverse​(double[] elements)
      Reverse an array of doubles.
      static float[] reverse​(float[] elements)
      Reverse an array of floats.
      static int[] reverse​(int[] elements)
      Reverse an array of ints.
      static long[] reverse​(long[] elements)
      Reverse an array of longs.
      static <T> T[] reverse​(T[] elements)
      Reverse an array of objects.
      • Methods inherited from class java.lang.Object

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

      • reverse

        public static <T> T[] reverse​(@Nonnull
                                      T[] elements)
        Reverse an array of objects.

        Not suitable for primitive types.

        Type Parameters:
        T - the Type of the array contents
        Parameters:
        elements - the array
        Returns:
        the reversed array
      • reverse

        public static int[] reverse​(@Nonnull
                                    int[] elements)
        Reverse an array of ints.
        Parameters:
        elements - the array
        Returns:
        the reversed array
      • reverse

        public static long[] reverse​(@Nonnull
                                     long[] elements)
        Reverse an array of longs.
        Parameters:
        elements - the array
        Returns:
        the reversed array
      • reverse

        public static double[] reverse​(@Nonnull
                                       double[] elements)
        Reverse an array of doubles.
        Parameters:
        elements - the array
        Returns:
        the reversed array
      • reverse

        public static float[] reverse​(@Nonnull
                                      float[] elements)
        Reverse an array of floats.
        Parameters:
        elements - the array
        Returns:
        the reversed array
      • reverse

        public static boolean[] reverse​(@Nonnull
                                        boolean[] elements)
        Reverse an array of booleans.
        Parameters:
        elements - the array
        Returns:
        the reversed array