A custom Map implementation with expiring entries
Posted on 2004-04-05
How would you write an efficient Map implementation that works just like HashMap, except for the following rules?
1) It only allows a maximum number of entries, specified at creation, at any time.
2) An entry is marked with the current timestamp when it is accessed with .get(), but without modifying the entry object in any way (i.e. this Map must still be able to contain any kind of Object).
3) When the map is full and another entry is added with .put(), the entry with the oldest timestamp is first dropped.