Duplicate :
|
|
Relates :
|
|
Relates :
|
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.