What I need is something like Hashtable which I will fill with prices that were actual at desired days.
For example: I will put two prices: January 1st: 100USD, March 5th: 89USD.
If I search my hashtable for price: hashtable.get(February 14th) I need it to give me back actual price which was entered at Jan. 1st because this is the last actual price. Normal hashtable implementation won’t give me back anything, since there is nothing put on that dat.
I need to see if there is such implementation which can find quickly object based on range of dates.
Off the top of my head, there are a couple ways, but I would use a
TreeMap<Date>(orCalendar, etc).When you need to pull out a
Date date, try the following:get(date)null, then the result is inheadMap(date).lastKey()One of those will work. Of course, check the size of
headMap(date)first becauselastKey()will throw anExceptionif it is empty.