Class Collections3


  • public final class Collections3
    extends Object
    • Method Detail

      • add

        public static <E> List<E> add​(List<? extends E> list,
                                      E element)
      • containsAll

        public static <K,​V> boolean containsAll​(Map<? extends K,​? extends V> map1,
                                                      Map<? extends K,​? extends V> map2)
        This method is null-hostile.
      • sorted

        public static <E extends Comparable<E>> boolean sorted​(List<E> list)
      • add

        public static <K,​V> Map<K,​V> add​(Map<K,​V> map,
                                                     K key,
                                                     V value)
      • add

        public static <E> Set<E> add​(Set<E> set,
                                     E element)
      • forEachPair

        public static <E1,​E2> void forEachPair​(Iterable<E1> iterable1,
                                                     Iterable<E2> iterable2,
                                                     BiConsumer<? super E1,​? super E2> action)
      • isDistinct

        public static <E> boolean isDistinct​(List<E> list)
      • hasDistinctValues

        public static <K,​V> boolean hasDistinctValues​(Map<K,​V> map)
      • ofNullable

        public static <E> Set<E> ofNullable​(@Nullable
                                            E element)
      • maximalElements

        public static <E> List<E> maximalElements​(Collection<? extends E> elements,
                                                  BiPredicate<? super E,​? super E> isLessThan)
        Computes a sub-list of elements which are maximal. The iteration order is preserved. Does not support null elements.
        Type Parameters:
        E - the type
        Parameters:
        elements - the elements
        isLessThan - returns true is the first argument is less than the second argument. It is only required that the order is transitive. The reflexive hull is added automatically.
        Returns:
        a sublist only containing maximal elements.
      • partition

        public static <E> List<Set<E>> partition​(Collection<? extends E> elements,
                                                 BiPredicate<? super E,​? super E> relation)
        Partition the elements using the given relation.
        Type Parameters:
        E - the element type.
        Parameters:
        elements - the collection containing the elements that are group into partitions.
        relation - the relation used to construct the partition. It is only required this relation is symmetric. The transitive and reflexive hull are computed automatically.
        Returns:
        the partition.
      • transformList

        public static <E1,​E2> List<E2> transformList​(List<E1> list,
                                                           Function<E1,​E2> transformer)
        Creates a new List by applying the transformer on each element of list.

        The implementation does not access Collection.isEmpty() or Collection.size()), since computing these values on live views might be expensive and cause a full traversal.

        Type Parameters:
        E1 - the element type of the input
        E2 - the element type of the return value
        Parameters:
        list - the input list.
        transformer - the translator function. It is not allowed to return null, since the used data-structures might be null-hostile.
        Returns:
        a new list containing all transformed objects
      • transformMap

        public static <K1,​K2> Map<K2,​BddSet> transformMap​(Map<K1,​BddSet> map,
                                                                      Function<K1,​K2> transformer)
      • transformMap

        public static <K1,​K2,​V> Map<K2,​V> transformMap​(Map<K1,​V> map,
                                                                         Function<K1,​K2> transformer,
                                                                         BiFunction<? super V,​? super V,​? extends V> valueMerger)
      • transformSet

        public static <E1,​E2> Set<E2> transformSet​(Set<E1> set,
                                                         Function<E1,​E2> transformer)
        Creates a new Set by applying the transformer on each element of set.

        The implementation does not access Collection.isEmpty() or Collection.size()), since computing these values on live views might be expensive and cause a full traversal.

        Type Parameters:
        E1 - the element type of the input
        E2 - the element type of the return value
        Parameters:
        set - the input set.
        transformer - the translator function. It is not allowed to return null, since the used data-structures might be null-hostile.
        Returns:
        a new set containing all transformed objects
      • union

        public static <E> Set<E> union​(Set<E> set1,
                                       Set<E> set2)
      • compare

        public static <E extends Comparable<? super E>> int compare​(Set<? extends E> s1,
                                                                    Set<? extends E> s2)
      • indexOf

        public static <E> int indexOf​(List<Set<E>> sets,
                                      E element)
        Returns the index of the first occurrence of the specified element in this list of sets, or -1 if this list does not contain the element. More formally, returns the lowest index i such that get(i).contains(o), or -1 if there is no such index.
        Parameters:
        sets - list of sets
        element - element to search for
        Returns:
        the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element