FileDocCategorySizeDatePackage
BoundedSizeMap.javaAPI DocExample359Mon Nov 13 14:59:00 GMT 2006collections

BoundedSizeMap.java

package collections;

import java.util.LinkedHashMap;
import java.util.Map;

public class BoundedSizeMap extends LinkedHashMap {
  private int maxEntries;
  public BoundedSizeMap(int maxEntries) {
    super(16, 0.75f, true);
    this.maxEntries = maxEntries;
  }
  protected boolean removeEldestEntry(Map.Entry eldest) {
    return size() > maxEntries;
  }
}