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

(coll) Add wrapper methods to Collections for NavigableSet and NavigableMap

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • 8
    • 7
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      There are no wrapper methods in java.util.Collections for NavigableSet or NavigableMap. Please consider adding the following:
      checkedNavigableSet
      checkedNavigableMap
      synchronizedNavigableSet
      synchronizedNavigableMap
      unmodifiableNavigableSet
      unmodifiableNavigableMap


      JUSTIFICATION :
      NavigableSet and NavigableMap provide highly useful enhancements to SortedSet and SortedMap. Returning unmodifiable forms of them is often a cheap way to provide encapsulation of internal data kept in a NavigableSet or NavigableMap, especially data of immutable objects.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would like the java.util.Collections class to have wrapper methods for NavigableSet and NavigableMap.
      ACTUAL -
      Currently, there are no wrapper methods for NavigableSet and NavigableMap.

      CUSTOMER SUBMITTED WORKAROUND :
      1. Use SortedSet and SortedMap, if the reduced functionality is acceptable.
      2.Write the wrappers oneself (which isn't as easy as it sounds, since all the returned Map.Entrys, collection views and descending views also need to be checked/unmodifiable).
      3. Use defensive copying instead of unmodifiable wrappers; use manual synchronization instead of synchronized wrappers.

            mduigou Mike Duigou
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: