zcwease / guava-libraries

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

Support for NavigableMap and NavigableSet in TreeMultimap #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The TreeMultimap implementation ought to support the NavigableMap 
interface. Need a quick way to get an ascending/descending iterator given 
a starting key.

Original issue reported on code.google.com by buko.ob...@gmail.com on 16 Mar 2008 at 9:52

GoogleCodeExporter commented 9 years ago
TreeMultimap cannot implement NavigableMap as it is not a map.  But if you 
clarify
your use cases we'll try to make sure it has the functionality you need.

Original comment by kevin...@gmail.com on 21 Mar 2008 at 10:53

GoogleCodeExporter commented 9 years ago
TreeMultimap.keySet() returns a SortedSet. You can call
TreeMultimap.keySet().tailSet(key).iterator() to get an ascending iterator with 
a
starting key. 

If for a given multimap, you consistently want a descending iterator, you can 
call
the TreeMap constructor with a comparator that reverses the natural ordering of 
keys.

However, there's no way to quickly generate ascending and descending iterators 
for a
particular multimap. For that to work, TreeMultimap.keySet() would have to 
return a
NavigableSet.

Original comment by jared.l....@gmail.com on 22 Mar 2008 at 12:59

GoogleCodeExporter commented 9 years ago
I'll deal with this eventually, might it might be a while until I get to it. 

There are two major factors involved. First, we want to keep supporting Java 5, 
which
lacks the NavigableSet and NavigableMap interfaces. Second, those interfaces 
have
tons of methods that we'd have to implement.

Original comment by jared.l....@gmail.com on 3 Apr 2008 at 5:23

GoogleCodeExporter commented 9 years ago
My current thoughts are that we're open to possibly having _implementations_ 
that
support NavigableFoo in the future, we should not get into attempting any 
interfaces
like NavigableKeysMultimap, NavigableValuesMultimap, etc. The complexity budget 
would
be way overspent at that point.  Also, we'll only be able to add Navigable* 
support
inasmuch as we can do so without breaking any backward compatibility with 1.0.  
I
think this is a livable situation.

Changing to Priority-Low as a way of saying we won't be thinking about this for 
a while.

Original comment by kevin...@gmail.com on 27 May 2008 at 6:55