If memory/performance is not a constraint*, you could simply use a TreeMap
, which has a subMap method that allows you to filter on a time window:
TreeMap<Date, Double> data = ...;
for (Double price : data.subMap(startDate, true, endDate, true).values()) {
//do something with price
}
*i.e. if you don't need to keep the prices as primitive doubles for example