package edu.brandeis.cs.steele.util;

import java.util.*;
import java.util.concurrent.*;

/** A fixed-capacity <code>Cache</code> that stores the <var>n</var> values associate
 * with the <var>n</var> most recently accessed keys.  Backed by an {@link ConcurrentMap}.
 * FIXME currently totally broken and incomplete
 */
public class ConcurrentLRUCache<K, V> extends LinkedHashMap<K, V> implements Cache<K, V> {
  private static final long serialVersionUID = 1L;
  private final ConcurrentHashMap<K, V> backingMap;

  protected final int capacity;

  public ConcurrentLRUCache(final int capacity) {
    this.capacity = capacity;
    this.backingMap = new ConcurrentHashMap();
  }

  public V put(K key, V value) {
    return super.put(key, value);
  }

  public V get(Object key) {
    return super.get(key);
  }

  public void clear() {
    super.clear();
  }

  protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
    // Return true to cause the oldest elm to be removed
    return size() > capacity;
  }
}

@@ -455,16 +455,17 @@
 D = 1L;%0A
+%0A
   privat
@@ -508,17 +508,16 @@
 ingMap;%0A
-%0A
   protec
@@ -664,16 +664,22 @@
 tHashMap
+%3CK, V%3E
 ();%0A  %7D%0A

kill some warnings