Class CollectionUtils

java.lang.Object
ru.cwcode.cwutils.collections.CollectionUtils

public class CollectionUtils extends Object
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • getRandomListEntry

      @Nullable public static <T> T getRandomListEntry(List<T> list)
    • getRandomArrayEntry

      @SafeVarargs public static <T> T getRandomArrayEntry(T... values)
    • shuffleArray

      @Deprecated public static void shuffleArray(int[] ar)
      Deprecated.
    • shuffleArray

      public static <T> T[] shuffleArray(T[] array)
    • combine

      @SafeVarargs public static <T> Collection<T> combine(Collection<T>... lists)
    • containsAny

      public static <T> boolean containsAny(Collection<T> one, Collection<T> two)
      Используйте HashSet для параметров, если коллекции достаточно большие
    • hasAllElements

      public static <T> boolean hasAllElements(Collection<T> toCheck, Collection<T> elements)
      Используйте HashSet для параметров, если коллекции достаточно большие
    • getStringOfArray

      public static String getStringOfArray(Object[] values)
    • toString

      public static String toString(Object[] values, String prefix, String suffix, boolean removeLastSuffix)
    • toString

      public static <T> String toString(List<T> values)
    • toString

      public static <T> String toString(List<T> values, String prefix, String suffix, boolean removeLastSuffix)
    • increment

      public static <T> int increment(T item, Map<T,Integer> map)
    • add

      public static <T> int add(T item, int toAdd, Map<T,Integer> map)
    • decrement

      public static <T> int decrement(T item, Map<T,Integer> map)
    • getRandomWeightedElement

      public static <T> T getRandomWeightedElement(Map<T,? extends Number> map)
    • getRandomWeightedElement

      public static <T> T getRandomWeightedElement(Collection<T> elements, Function<T,? extends Number> chanceExtractor)
    • getFirstAvailableID

      public static int getFirstAvailableID(Collection<Integer> set, int minID)