I'm looking for a collection that would suit my scenario:
- I will be inserting key-value pairs (both integers) of ID and timestamp. The ID must be unique.
- At some interval I will be checking that collection for "expired" items (as in the timestamp + X < current_timestamp) and will need to both remove the key-value pair and act on the key.
I stated that I'm looking for sorted collection, because I think with the collection sorted by value (descending order) I could break the loop over the collection at the point I reach first not "expired" timestamp (that would mean rest of them is active too).
I predict that 95% of my entries will not be "expired" at the time I loop over them.
There will be way more inserts/modifications than reads.
I couldn't find anything that would match this scenario, the closest one is SortedMap.
Is there anything that would be more suitable? Perhaps completely other approach?
I think it's also important to point out it will hold up to 10000 keys (pairs).