01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.util;
07:
08: //#ifdef JDK14
09: import java.util.LinkedHashMap; //#endif
10: //#ifdef JDK13
11: /*
12: import java.util.HashMap;
13: */
14:
15: //#endif
16: import java.util.Map;
17:
18: /**
19: * This class implements a small LRU object cache.
20: */
21: public class SmallLRUCache
22: //#ifdef JDK14
23: extends LinkedHashMap
24: //#endif
25: //#ifdef JDK13
26: /*
27: extends HashMap
28: */
29: //#endif
30: {
31:
32: private static final long serialVersionUID = 3643268440910181829L;
33: private int size;
34:
35: public SmallLRUCache(int size) {
36: this .size = size;
37: }
38:
39: //#ifdef JDK14
40: protected boolean removeEldestEntry(Map.Entry eldest) {
41: return size() > size;
42: }
43: //#endif
44: }
|