On 29 Maj, 06:01, Raja <rokkamr...@gmail.comwrote:
Hi,
I am trying to do a simple design of an LRU Cache . Can anyone
please guide me in this regard. I have a basic idea ADT to be used
using linked list and reference counted array. But I want to know the
best method to design , the classes , interfaces etc required .
Depends on your needs and constraints. A simple version would be to
use a vector to store a struct describing whatever it is that you
cache, and each time you access one of them you update a time-stamp.
When you need to replace one of them you can either sort the vector on
the time-stamp, or, if you need the order unchanged, make a copy and
sort the copy.
For more efficient implementations you might want to get a book on
operating systems, or google, or check wikipedia.
--
Erik Wikström