RFC: draft API for JEP 269 Convenience Collection Factories (original) (raw)
Louis Wasserman lowasser at google.com
Sat Oct 10 16:10:41 UTC 2015
- Previous message: RFC: draft API for JEP 269 Convenience Collection Factories
- Next message: RFC: draft API for JEP 269 Convenience Collection Factories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm unclear on whether the question is where Guava stopped, or why we included the fixed-args versions as well as the varargs versions?
Part of the answer, of course, is that those factories predate @SafeVarargs, and frankly even now Guava doesn't really depend on Java 7.
If you're asking about why we stopped where we did, we collected actually rather a lot of data on the size of static collection constants using immutable collections, both with builder syntax and without. https://github.com/google/guava/issues/2071#issuecomment-126468933 has the statistics (in terms of ratios, not absolute numbers), but we found that there was right about an exponential trend: static collection constants of size n+1 were ~half as common as collection constants of size n.
On Sat, Oct 10, 2015 at 6:56 AM Remi Forax <forax at univ-mlv.fr> wrote:
----- Mail original ----- > De: "Stephen Colebourne" <scolebourne at joda.org> > À: "core-libs-dev" <core-libs-dev at openjdk.java.net> > Envoyé: Vendredi 9 Octobre 2015 15:11:47 > Objet: Re: RFC: draft API for JEP 269 Convenience Collection Factories > > On 9 October 2015 at 00:39, Stuart Marks <stuart.marks at oracle.com> wrote:
[...] > > 2. Other concrete collection factories. > > > > I've chosen to provide factories for the concrete collections ArrayList, > > HashSet, and HashMap, since those seem to be the most commonly used. Is > > there a need to provide factories for other concrete collections, such as > > LinkedHashMap? > > LinkedHashMap definitely > LinkedList definitely not (as its very slow and use should not be > encouraged). > TreeSet/TreeMap, maybe, they'd need an extra parameter though. There is an issue with LinkedHashMap (resp LinkedHashSet), it inherits from HashMap /facepalm/, and static methods are accessible through class inheritance /facepalm/. So if LinkedHashMap doesn't declare some methods of(), LinkedHashMap.of("foo") will return a HashMap :( cheers, Rémi
- Previous message: RFC: draft API for JEP 269 Convenience Collection Factories
- Next message: RFC: draft API for JEP 269 Convenience Collection Factories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]