Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8184694

add lexicographic comparator methods for collections

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs

      There should be methods that compare two collections lexicographically, something like this on the Collections class:

      public static <T> int compare(Collection<? extends T> c1,
                                        Collection<? extends T> c2,
                                        Comparator<? super T> cmp)

      public static <T extends Comparable<? super T>>
          int compare(Collection<? extends T> c1, Collection<? extends T> c2)

      Of course, the collections must have a well-defined iteration order, such as List, LinkedHashSet, or SortedSet.

      Update 2023-10-23: the arguments could be SequencedCollection to ensure encounter order is well-defined.

            smarks Stuart Marks
            smarks Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: