Class CollectionUtils

  • public class CollectionUtils
    extends java.lang.Object
    Collections-related utility methods.
    • Constructor Summary

      Constructor Description
    • Method Summary

      Modifier and Type Method Description
      static <E> java.util.ArrayList<E> arrayAsArrayList​(E... elements)  
      static <E> java.util.ArrayList<E> asArrayList​(E first, E... other)  
      static <E> java.util.ArrayList<E> asArrayList​(E first, E second, E... other)  
      static <E> java.util.List<java.util.List<E>> eagerPartition​(java.util.List<E> list, int size)  
      static void ensureNoSelfReferences​(java.lang.Object value)  
      static boolean isEmpty​(java.lang.Object[] array)
      Checks if the given array contains any elements.
      static <E> java.util.ArrayList<E> iterableAsArrayList​(java.lang.Iterable<? extends E> elements)  
      static <E> java.util.LinkedList<E> newLinkedList​(java.lang.Iterable<E> elements)  
      static <E> java.util.ArrayList<E> newSingletonArrayList​(E element)  
      static <T> java.util.List<T> rotate​(java.util.List<T> list, int distance)
      Return a rotated view of the given list with the given distance.
      static void sort​(double[] array, int len)  
      static void sort​(float[] array, int len)  
      static void sort​(long[] array, int len)  
      static void sort​(com.carrotsearch.hppc.ObjectArrayList<byte[]> array)  
      static void sort​(org.apache.lucene.util.BytesRefArray bytes, int[] indices)  
      static void sortAndDedup​(com.carrotsearch.hppc.ObjectArrayList<byte[]> array)  
      static int sortAndDedup​(org.apache.lucene.util.BytesRefArray bytes, int[] indices)  
      static int[] toArray​(java.util.Collection<java.lang.Integer> ints)  
      • Methods inherited from class java.lang.Object

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

      • CollectionUtils

        public CollectionUtils()
    • Method Detail

      • sort

        public static void sort​(long[] array,
                                int len)
      • sort

        public static void sort​(float[] array,
                                int len)
      • sort

        public static void sort​(double[] array,
                                int len)
      • isEmpty

        public static boolean isEmpty​(java.lang.Object[] array)
        Checks if the given array contains any elements.
        array - The array to check
        false if the array contains an element, true if not or the array is null.
      • rotate

        public static <T> java.util.List<T> rotate​(java.util.List<T> list,
                                                   int distance)
        Return a rotated view of the given list with the given distance.
      • sortAndDedup

        public static void sortAndDedup​(com.carrotsearch.hppc.ObjectArrayList<byte[]> array)
      • sort

        public static void sort​(com.carrotsearch.hppc.ObjectArrayList<byte[]> array)
      • toArray

        public static int[] toArray​(java.util.Collection<java.lang.Integer> ints)
      • ensureNoSelfReferences

        public static void ensureNoSelfReferences​(java.lang.Object value)
      • sort

        public static void sort​(org.apache.lucene.util.BytesRefArray bytes,
                                int[] indices)
      • sortAndDedup

        public static int sortAndDedup​(org.apache.lucene.util.BytesRefArray bytes,
                                       int[] indices)
      • iterableAsArrayList

        public static <E> java.util.ArrayList<E> iterableAsArrayList​(java.lang.Iterable<? extends E> elements)
      • arrayAsArrayList

        public static <E> java.util.ArrayList<E> arrayAsArrayList​(E... elements)
      • asArrayList

        public static <E> java.util.ArrayList<E> asArrayList​(E first,
                                                             E... other)
      • asArrayList

        public static <E> java.util.ArrayList<E> asArrayList​(E first,
                                                             E second,
                                                             E... other)
      • newSingletonArrayList

        public static <E> java.util.ArrayList<E> newSingletonArrayList​(E element)
      • newLinkedList

        public static <E> java.util.LinkedList<E> newLinkedList​(java.lang.Iterable<E> elements)
      • eagerPartition

        public static <E> java.util.List<java.util.List<E>> eagerPartition​(java.util.List<E> list,
                                                                           int size)