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.
|