2010/4/17 assembling signals <assembling.sign...@yandex.ru>

> Hello, everyone!
>
> In the Collections utility class we have
>
> * emptyMap()
> * emptySet()
>
> * unmodifiableSet(...)
> * unmodifiableMap(...)
> * unmodifiableSortedSet(...)
> * unmodifiableSortedMap(...)
>
> So we have no
>
> * emptySortedMap()
> * emptySortedSet()
>
> I have several times encountered situations where methods needed either
> SortedSet or SortedMap.
>
> Do you think in would be appropriate to introduce the two proposed methods?
>
>
Why not just changing the implementation of the existing emptyMap() and
emptySet(), so they return an object that is additionally sorted? This would
require a typecast, e.g. SortedMap<T> map =
(SortedMap<T>)Collections.emptyMap(); but wouldn't require changing the
existing API, or adding any new API. Just make very clear in the
documentation that the typecast is valid only @since 1.7.

A+
Osvaldo

Reply via email to