InterviewSolution
| 1. |
Write A Program To Implement Lru Cache Using Generics ? |
|
Answer» ONE hint is that LinkedHashMap can be USED IMPLEMENT fixed size LRU cache where one needs to remove ELDEST entry when Cache is full. LinkedHashMap provides a method CALLED removeEldestEntry() which is called by put() and putAll() and can be used to instruct to remove eldest entry. you are free to come up with your own implementation as long as you have a written a working version along with Unit test. One hint is that LinkedHashMap can be used implement fixed size LRU cache where one needs to remove eldest entry when Cache is full. LinkedHashMap provides a method called removeEldestEntry() which is called by put() and putAll() and can be used to instruct to remove eldest entry. you are free to come up with your own implementation as long as you have a written a working version along with Unit test. |
|