Is there a data structure for this type of list/map?
- by Nick
Perhaps there's a name for what I want, but I'm not aware of it. I need something similar to a LinkedHashMap in Java, but where it returns the 'previous' value if there's no value at the specified key.
That is, I have a list of objects stored by an integer key (which is in units of time in my case):
; key->value
10->A
15->B
20->C
So, if I were to query for a value for key 0-9, it would return null. The special part is if I queried for something 10 <= i <= 14 it would return A. Or, for i = 20, it would return C.
Is there a data structure for this?