RFR(m): 8139233 add initial compact immutable collection implementations
Remi Forax
forax at univ-mlv.fr
Wed May 4 22:15:57 UTC 2016
----- Mail original -----
> De: "Peter Levart" <peter.levart at gmail.com>
> À: "Stephen Colebourne" <scolebourne at joda.org>, "core-libs-dev" <core-libs-dev at openjdk.java.net>
> Envoyé: Mercredi 4 Mai 2016 23:58:13
> Objet: Re: RFR(m): 8139233 add initial compact immutable collection implementations
>
>
>
> On 05/04/2016 05:25 PM, Stephen Colebourne wrote:
> > I disagree with altering the iteration order. Guava's ImmutableSet and
> > ImmutableMap have reliable iteration specified to match creation
> > order. This aspect of the design is very useful.
> >
> > Stephen
>
> Are they also O(1) on lookup at the same time?
yes, the elements are stored twice (in two different arrays, one to keep the ordering (minus duplicates) the other to guarantee fast access.
so it's 0(1) but it's not a 'compact' implementation.
>
> Altering iteration order from VM run to VM run is a double-edged sword.
> I can understand that by doing so, programs written to depend on
> iteration order are practically not possible. In the absence of such
> "randomization", a simple change of hashCode algorithm of some element
> of the collection (could be a user class) could break the program. But
> as Alan pointed out it is also harder to reproduce problems that way.
> OTOH one might argue that randomization actually prevents such problems
> to appear in the first place. It forces the programs to be written in a
> way so that they don't depend on any particular iteration order as it
> uncovers any potential problems dependent on iteration order early in
> the development phase.
>
> Regards, Peter
>
>
cheers,
Rémi
More information about the core-libs-dev
mailing list