KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > util > LRUCache


1 /*
2  * Created on Jun 15, 2004
3  */

4 package org.roller.util;
5
6 import java.util.Map JavaDoc;
7
8 // David Flanaghan: http://www.davidflanagan.com/blog/000014.html
9
public class LRUCache extends java.util.LinkedHashMap JavaDoc
10 {
11     protected int maxsize;
12     public LRUCache(int maxsize)
13     {
14         super(maxsize*4/3 + 1, 0.75f, true);
15         this.maxsize = maxsize;
16     }
17     protected boolean removeEldestEntry(Map.Entry JavaDoc eldest) {
18         return size() > this.maxsize;
19     }
20 }
21     
22
Popular Tags