yangxu998 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Provide Maps.newTreeMap(Map) #545

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There's a TreeMap(Map) constructor, so why restrict Maps.newTreeMap to only 
accept SortedMap?

Original issue reported on code.google.com by yogy.nam...@gmail.com on 9 Feb 2011 at 7:09

GoogleCodeExporter commented 9 years ago
We don't want to support TreeMap(Map) with an arbitrary Map. Someone could 
provide a map without a comparator whose keys aren't comparable. The JDK has 
such a method for compatibility with the pre-generic API.

Either of the following methods is feasible, but I don't think we should add 
more newTreeMap overloads.

static <C, K extends C, V> TreeMap<K,V> newTreeMap(Comparator<C> comparator, 
Map<? extends K, ? extends V)

static <K extends Comparable,V> TreeMap<K,V> newTreeMap(Map<? extends K, ? 
extends V>)

Original comment by jared.l....@gmail.com on 14 Feb 2011 at 10:48

GoogleCodeExporter commented 9 years ago
Slightly related: http://code.google.com/p/guava-libraries/issues/detail?id=535

Original comment by nev...@gmail.com on 14 Feb 2011 at 11:35

GoogleCodeExporter commented 9 years ago

Original comment by kevin...@gmail.com on 19 Feb 2011 at 11:49

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09