Any chance to see EnumSet implement SortedSet in JDK8?
mike.skells at talk21.com
mike.skells at talk21.com
Fri Aug 12 05:46:02 PDT 2011
Your argument is flawed
The complexity of the operations is not defined by the interface or the presence or absence of the interface
If you have complexity algo checks then these can only be applied to known classes where the complexity is defined in the interface or class
As such the code that infers this behaviour is broken and needs to be fixed.
If the arbitrary missasumptions as to non functional characteristics is the driver that blocks evolution of the java ecosystem then java is dead and we may as well keep starting again.
As an aside IMO the complexity specification issue could be better addressed with the interface evolution in Java 8. There have been other discussion of improvements to performance of the algos in collections that do require this metadata. This would allow the broken code to be fixed
Sent from my BlackBerry® wireless device
From: Rémi Forax <forax at univ-mlv.fr>
Sender: core-libs-dev-bounces at openjdk.java.net
Date: Fri, 12 Aug 2011 14:18:46
To: <core-libs-dev at openjdk.java.net>
Subject: Re: Any chance to see EnumSet implement SortedSet in JDK8?
On 08/12/2011 01:03 AM, Joe Darcy wrote:
> On 8/11/2011 1:56 PM, Rémi Forax wrote:
>> On 08/11/2011 10:19 PM, assembling signals wrote:
>>> Hello, community!
>>> Enum does implement Comparable, while EnumSet does NOT implement
>>> SortedSet and EnumMap doesn NOT implement SortedMap.
>>> Should I file a bug report (RFE), would there be a chance to see
>>> this being implemented in JDK8?
>> I've asked the same question with NavigableSet/Map during the JDK6
>> so you should find the answer by Doug Lea on the concurrency-interest
>> concurrency-interest at cs.oswego.edu
>> Furthermore, you can't retrofit EnumSet to implement SortedSet
>> (an interface that already exists)
>> because since 1.5, a lot of code was written and some may rely on
>> the fact that EnumSet doesn't implement SortedSet.
> Actually, that is not the sort of compatibility contract we usually
> worry about enforcing over time. For example, in JDK 7 I retrofitted
> the java.io.Closeable interface to several long-standing classes with
> close methods that were not retrofitted before.
Hi Joe, I disagree,
SortedSet is not Closeable.
It's not rare to use instanceof to check the interface implemented by a
to guarantee the complexity of an algorithm.
It's a common trick, and there is no better alternative.
Most operations on an EnumSet are done in O(1),
most implementations of SortedSet offers operations that are done in
If you retrofit EnumSet to implement SortedSet, the risk to change the
of an existing algorithm is far from negligible.
More information about the core-libs-dev