Class CollectionUtils

java.lang.Object
org.pepsoft.util.CollectionUtils

public final class CollectionUtils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static BitSet
    bitSetOf(int... values)
     
    static <E> ArrayList<E>
    copyOf(List<E> list)
    Null-safe method for copying a List.
    static <K, V> HashMap<K,V>
    copyOf(Map<K,V> map)
    Null-safe method for copying a Map.
    static <E> HashSet<E>
    copyOf(Set<E> set)
    Null-safe method for copying a Set.
    static <T> List<T>
    listOf(List<? extends T>... lists)
    Creates an unmodifiable and efficient (for RandomAccess lists) List which is the concatenation of several other Lists.
    static int
    max(int[] values)
    Returns the highest value from an array of ints, or Integer.MIN_VALUE if the array is empty.
    static <T> List<T>
    nullAnd(Collection<T> collection)
    Prepends a null to a collection.
    static int
    unsignedMax(byte[] values)
    Returns the highest value from an array of bytes, interpreted as unsigned values, or Integer.MIN_VALUE if the array is empty.
    static int
    unsignedMax(short[] values)
    Returns the highest value from an array of shorts, interpreted as unsigned values, or Integer.MIN_VALUE if the array is empty.

    Methods inherited from class java.lang.Object

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

    • bitSetOf

      public static BitSet bitSetOf(int... values)
    • listOf

      @SafeVarargs public static <T> List<T> listOf(List<? extends T>... lists)
      Creates an unmodifiable and efficient (for RandomAccess lists) List which is the concatenation of several other Lists.
    • max

      public static int max(int[] values)
      Returns the highest value from an array of ints, or Integer.MIN_VALUE if the array is empty.
    • unsignedMax

      public static int unsignedMax(short[] values)
      Returns the highest value from an array of shorts, interpreted as unsigned values, or Integer.MIN_VALUE if the array is empty.
    • unsignedMax

      public static int unsignedMax(byte[] values)
      Returns the highest value from an array of bytes, interpreted as unsigned values, or Integer.MIN_VALUE if the array is empty.
    • nullAnd

      public static <T> List<T> nullAnd(Collection<T> collection)
      Prepends a null to a collection.
      Type Parameters:
      T - The type of collection.
      Parameters:
      collection - The collection to which to prepend a null.
      Returns:
      A list containing a null and then the contents of collection.
    • copyOf

      public static <E> ArrayList<E> copyOf(List<E> list)
      Null-safe method for copying a List.
      Type Parameters:
      E - The element type of the list.
      Parameters:
      list - The list to copy.
      Returns:
      A new ArrayList with the contents of the provided list, or null if list was null.
    • copyOf

      public static <E> HashSet<E> copyOf(Set<E> set)
      Null-safe method for copying a Set.
      Type Parameters:
      E - The element type of the set.
      Parameters:
      set - The set to copy.
      Returns:
      A new HashSet with the contents of the provided set, or null if set was null.
    • copyOf

      public static <K, V> HashMap<K,V> copyOf(Map<K,V> map)
      Null-safe method for copying a Map.
      Type Parameters:
      K - The key type of the map.
      V - The value type of the map.
      Parameters:
      map - The map to copy.
      Returns:
      A new HashMap with the contents of the provided map, or null if map was null.