I am trying to do some interpolation, at xxxxx .
A clean implementation is to use the
map.get( key )
to return an interpolated value, if the real value does not exist.
However in doing this I would like to access
n-keys either side of the key I am requesting.
The current SortMap interface only allows me to get at the value either side of the key value (using headMap.lastKey() &
This is inadequate for some kinds of interpolation where I need several keys either side of the key in question.
As a general solution to this problem it seems reasonable that Sorted classes should return a ListIterator as well as an iterator.
(Review ID: 34731)
It is easy to get multiple entries *following* a given key, merely
by iterating over tailMap(k).entrySet(). It is more difficult to get
multiple keys preceding a given key. (You're stuck doing the
headMap(k).lastKey() trick repeatedly, which is ugly and not very
We initially did provide a List view of SortedMap (actually TreeMap), but
backed away from this as it required implementers to support "rank operations"
(i.e., positional access to SortedMap entries). This is a significant
burden for many Map implementations, including Red-Black trees. It would
be nice if we could provide iteration without providing positional access,
but the current interfaces don't make this easy.
I'll continue to think about this problem, in the hope that it can
be addressed prior to FCS.
Bidirectional navigation will be addressed by the Navigable* interfaces,
the higher/lower/ceiling/floor methods,
the descending iterator methods,
implemented in TreeMap and TreeSet and the new ConcurrentSkipList* classes,
coming with the integration of JSR166x.
xxxxx@xxxxx 2005-05-10 02:34:56 GMT