Class ListUtils

java.lang.Object
net.mcreator.util.ListUtils

public class ListUtils extends Object
  • Constructor Details

    • ListUtils

      public ListUtils()
  • Method Details

    • merge

      @SafeVarargs public static <T> List<T> merge(Collection<T>... collections)
    • mergeNoDuplicates

      @SafeVarargs public static <T> Set<T> mergeNoDuplicates(Collection<T>... collections)
    • intersect

      public static <T> Collection<T> intersect(Collection<T> a, Collection<T> b)
    • rearrange

      public static <T> void rearrange(List<T> items, T input)
    • getRandomItem

      public static <T> T getRandomItem(T[] list)
    • getRandomItem

      public static <T> T getRandomItem(List<T> list)
    • getRandomItem

      public static <T> T getRandomItem(Random random, T[] list)
    • getRandomItem

      public static <T> T getRandomItem(Random random, List<T> list)
    • cartesianProduct

      public static <K,V> List<Map<K,V>> cartesianProduct(Map<K, ? extends List<V>> input)
      Generates the full Cartesian product of a set of keys and their possible values.

      Example: If the map contains:

        A -> [1, 2]
        B -> [true, false]
      

      The output will be a list containing:

        {A=1, B=true}
        {A=1, B=false}
        {A=2, B=true}
        {A=2, B=false}
      
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      input - map of keys and their possible values; order of keys defines output order
      Returns:
      all combinations as a list of maps (each map is a unique combination)