1 8 package com.ibm.icu.impl; 9 10 import java.util.Map ; 14 15 18 public class LRUMap extends LinkedHashMap { 19 private static final long serialVersionUID = -8178106459089682120L; 20 21 private static final int DEFAULT_MAXCAPACITY = 64; 22 private static final int DEFAULT_INITIALCAPACITY = 16; 23 private static final float DEFAULT_LOADFACTOR = 0.75F; 24 25 private final int maxCapacity; 26 27 31 public LRUMap() { 32 super(DEFAULT_INITIALCAPACITY, DEFAULT_LOADFACTOR, true); 33 maxCapacity = DEFAULT_MAXCAPACITY; 34 } 35 36 43 public LRUMap(int initialCapacity, int maxCapacity) { 44 super(initialCapacity, DEFAULT_LOADFACTOR, true); 45 this.maxCapacity = maxCapacity; 46 } 47 48 51 protected boolean removeEldestEntry(Map.Entry eldest) { 52 return (size() > maxCapacity); 53 } 54 } 55 | Popular Tags |