How about Collections.emptySorted[Set|Map] ?
Osvaldo Doederlein
opinali at gmail.com
Sat Apr 17 17:03:30 UTC 2010
2010/4/17 assembling signals <assembling.signals at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20100417/f371ef6c/attachment.html>
More information about the core-libs-dev
mailing list