JDK-4137464 : (coll) TreeMap should have bi-directional iterator
  • Type: Enhancement
  • Status: Resolved
  • Resolution: Fixed
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Priority: P5
  • Affected Version: 1.2.0
  • OS: generic
  • CPU: generic
  • Submit Date: 1998-05-12
  • Updated Date: 2012-10-08
  • Resolved Date: 2005-09-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6
6 b51Resolved
Description

Name: rm29839			Date: 05/12/98


Robin Sharp @ reuters

I am trying to select a Java class to support TimeSeries. 

The closest I can get to a TimeSeries is the TreeMap.

The problem is that the TreeMap returns a uni-directional iterator. I need a bi-directional iterator (like the ListIterator). 

The reason for needing this is when I want to do  interpolation between two points. I need to go back and forth from a particular point to get values on either side of a date so I can do some linear interpolation.

It seems semantically the TreeMap has the same linear properties as a List, so semantically I don't see this as a problem.

Writing a bi-directional iterator does not seem to be too difficult after looking at the source code.

Ideally I would like a method like.

BiDirectionalIterator getIterator( Object key );

It seems to me that this simple extension to the code would make it hugely more powerful/useful

robn sharp @ reuters
(Review ID: 28445)
======================================================================

To: ronan.mandel@Eng
Date: Wed, 13 May 1998 01:01:14 -0700
From: "Robin Sharp" <###@###.###>
Mime-Version: 1.0
X-Sent-Mail: off
Subject: Re: Re: TreeMap should have bi-directional iterator
X-Sender-Ip: 194.75.134.116
Content-Transfer-Encoding: 7bit

I would like to offer a slightly improved suggestion. Which I have implemented. Which is to extend the Map and Set interfaces with an OrderedMap and OrderedSet. The only method they have that the Map and Set do not have is:- 

public ListIterator getListIterator(); (i.e. the bi-directional iterator).

I have found these necessary when writing time-series classes. When interpolating I need the Set functionality so the points are unambigious. However at different times I need to be able to add more than one event on the same date; so I would use the Map functionality here.

Thanks Robin.

Comments
EVALUATION This is being fixed by the JSR166 expert group maintenance. ###@###.### 2005-03-09 03:00:11 GMT
2005-03-09

WORK AROUND Name: rm29839 Date: 05/12/98 Re-write TreeMap ======================================================================
2004-09-08