01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.management.stats;
05:
06: import java.util.LinkedHashMap;
07: import java.util.Map;
08:
09: public class LRUMap extends LinkedHashMap {
10: private final static int NO_LIMIT = -1;
11:
12: private final int maxSize;
13:
14: public LRUMap() {
15: this (NO_LIMIT);
16: }
17:
18: public LRUMap(int maxSize) {
19: super (100, 0.75f, true);
20: this .maxSize = maxSize;
21: }
22:
23: protected boolean removeEldestEntry(Map.Entry eldest) {
24: if (maxSize != NO_LIMIT) {
25: return size() >= this .maxSize;
26: } else {
27: return false;
28: }
29: }
30: }
|