Class ListUtil



  • public class ListUtil
    extends Object
    • Constructor Detail

      • ListUtil

        public ListUtil()
    • Method Detail

      • shuffle

        public static <T> void shuffle(List<T> list,
                                       int nswaps)
        Type Parameters:
        T - the type of the list (implicit).
        Parameters:
        list - the list to shuffle.
        nswaps - the number of swaps to perform.
      • swap

        public static <T> void swap(List<T> list,
                                    int a,
                                    int b)
      • asByteArray

        public static byte[] asByteArray(List<Byte> list)
      • asShortArray

        public static short[] asShortArray(List<Short> list)
      • asIntArray

        public static int[] asIntArray(List<Integer> list)
      • asLongArray

        public static long[] asLongArray(List<Long> list)
      • asFloatArray

        public static float[] asFloatArray(List<Float> list)
      • asDoubleArray

        public static double[] asDoubleArray(List<Double> list)
      • asCharArray

        public static char[] asCharArray(List<Character> list)
      • asBooleanArray

        public static boolean[] asBooleanArray(List<Boolean> list)
      • prepended

        public static <T> List<T> prepended(List<T> list,
                                            T element)
        Create an unmodifiable list that contains the elements of the specified list plus the additional element prepended at its front.
      • appended

        public static <T> List<T> appended(List<T> list,
                                           T element)
        Create an unmodifiable list that contains the elements of the specified list plus the additional element append at its tail.
      • last

        public static <T> T last(List<T> list)
        Get the last element of the specified list.
      • removeLast

        public static <T> T removeLast(List<T> list)
        Remove the last element of the specified list.