United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4137464 : (coll) TreeMap should have bi-directional iterator

Details
Type:
Enhancement
Submit Date:
1998-05-12
Status:
Resolved
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2005-09-04
Component:
core-libs
OS:
generic
Sub-Component:
java.util:collections
CPU:
generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
1.2.0
Fixed Versions:

Related Reports

Sub Tasks

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



Hardware and Software, Engineered to Work Together