0

i know about LRU algorithm,but how to determine the calculation is key point.if the space is not enough,i want to find some files's weight which are below,then delete them and put in some files's weight which are high weight.some one ever did this?

  • i want to develop a function that when the disk space it not enough, delete some files which weight is below and put in some files which weight is high – user3804288 Jul 25 '14 at 02:28

1 Answers1

0

Here are a few implementations:

1) http://www.careercup.com/question?id=14113740

2) How would you implement an LRU cache in Java?

3) http://www.geeksforgeeks.org/implement-lru-cache/

Community
  • 1
  • 1
Devarsh Desai
  • 5,984
  • 3
  • 19
  • 21
  • i don't want the lru implementation,i want space replacement algorithm.but thank you – user3804288 Jul 25 '14 at 02:39
  • No worries! to my understanding, LRU and space replacement are the same algorithm, i thought? In LRU, when a page(or file) is least used, and there need there's an opportunity to replace it with something more useful, it's done. There by saving space. I was wondering if you could please clarify on the difference between the above and what you're looking for? – Devarsh Desai Jul 25 '14 at 02:44
  • how to determine a page(or file) is least used.i want this algorithm – user3804288 Jul 25 '14 at 02:55
  • I believe those links explain that process? Essentially all of the links explain that you have to use a combination of a doubly linked list and hashmap. Please take a look and let me know if you have any specific questions! – Devarsh Desai Jul 25 '14 at 02:57
  • yes,the space is limit.if the list size is 10,but i have 13 files,they are the same .how to determine which is put in the list. – user3804288 Jul 25 '14 at 03:09
  • Here is the wikipedia for cache algorithms + LRU: http://en.wikipedia.org/wiki/Least_Recently_Used#LRU; you should read up on it and get a better understanding of what you're trying to implement. – Devarsh Desai Jul 25 '14 at 03:15