Is there a Java data structure that is effectively an ArrayList with double indicies and built-in in

Posted by Bob Cross on Stack Overflow See other posts from Stack Overflow or by Bob Cross
Published on 2010-04-20T14:29:35Z Indexed on 2010/04/20 14:33 UTC
Read the original article Hit count: 165

I am looking for a pre-built Java data structure with the following characteristics:

  1. It should look something like an ArrayList but should allow indexing via double-precision rather than integers. Note that this means that it's likely that you'll see indicies that don't line up with the original data points (i.e., asking for the value that corresponds to key "1.5").

  2. As a consequence, the value returned will likely be interpolated. For example, if the key is 1.5, the value returned could be the average of the value at key 1.0 and the value at key 2.0.

  3. The keys will be sorted but the values are not ensured to be monotonically increasing. In fact, there's no assurance that the first derivative of the values will be continuous (making it a poor fit for certain types of splines).

  4. Freely available code only, please.

For clarity, I know how to write such a thing. In fact, we already have an implementation of this and some related data structures in legacy code that I want to replace due to some performance and coding issues.

What I'm trying to avoid is spending a lot of time rolling my own solution when there might already be such a thing in the JDK, Apache Commons or another standard library. Frankly, that's exactly the approach that got this legacy code into the situation that it's in right now....

Is there such a thing out there in a freely available library?

© Stack Overflow or respective owner

Related posts about java

Related posts about data-structures