Class Utils


  • public final class Utils
    extends Object
    Some utilities.
    • Method Detail

      • minMax

        public static <T extends Comparable<T>> Pair<T> minMax​(Iterable<T> items)
        Identifies the minimum and maximum elements from an iterable, according to the natural ordering of the elements.
        Type Parameters:
        T - The type of the elements.
        Parameters:
        items - An Iterable object with the elements
        Returns:
        A pair with the minimum and maximum elements.
      • randomSample

        public static <T> List<T> randomSample​(Collection<T> collection,
                                               int n)
        Randomly chooses elements from the collection.
        Type Parameters:
        T - The type of the elements.
        Parameters:
        collection - The collection.
        n - The number of elements to choose.
        Returns:
        A list with the chosen elements.