This is a follow-up question from my previous question.
I'm trying to implement a NavigableMap
defined as NavigableMap<Timestamp, Event>
. I would need this map to be like a cache for me. Every 5 minutes I refresh this NavigableMap
.
One thread updates this NavigableMap
, and another one reads from it, so it needs to be thread-safe. Whenever I have a request, I would need to grab a subset list of Events
whose timestamps are within a given start
and end
time.
What is the most efficient way to convert a NavigableMap
to this subset list, say ArrayList
? And what's the thread-safe implementation of this interface?
Apparently NavigableMap
has a sub-map method as well as floor
and ceiling
, but I don't see anything to convert to a list with a start and end time.