提交 e77b4b4a authored 作者: Thomas Mueller's avatar Thomas Mueller

LIRS replacement algorithm

上级 36415f3f
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
*/ */
package org.h2.dev.store.btree; package org.h2.dev.store.btree;
import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -37,7 +37,7 @@ import java.util.Set; ...@@ -37,7 +37,7 @@ import java.util.Set;
* @param <K> the key type * @param <K> the key type
* @param <V> the value type * @param <V> the value type
*/ */
public class CacheLIRS<K, V> implements Map<K, V> { public class CacheLIRS<K, V> extends AbstractMap<K, V> implements Map<K, V> {
/** /**
* The maximum memory this cache should use. * The maximum memory this cache should use.
...@@ -481,15 +481,6 @@ public class CacheLIRS<K, V> implements Map<K, V> { ...@@ -481,15 +481,6 @@ public class CacheLIRS<K, V> implements Map<K, V> {
return mapSize - queue2Size; return mapSize - queue2Size;
} }
/**
* Check whether there are any resident entries in the map.
*
* @return true if there are no keys
*/
public boolean isEmpty() {
return size() == 0;
}
/** /**
* Check whether there is a resident entry for the given key. * Check whether there is a resident entry for the given key.
* *
...@@ -500,27 +491,6 @@ public class CacheLIRS<K, V> implements Map<K, V> { ...@@ -500,27 +491,6 @@ public class CacheLIRS<K, V> implements Map<K, V> {
return e != null && e.value != null; return e != null && e.value != null;
} }
/**
* Check whether there are any keys for the given value.
*
* @return true if there is a key for this value
*/
public boolean containsValue(Object value) {
return values().contains(value);
}
/**
* Add all entries of the given map to this map. This method will use the
* average memory size.
*
* @param m the source map
*/
public void putAll(Map<? extends K, ? extends V> m) {
for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) {
put(e.getKey(), e.getValue());
}
}
/** /**
* Get the set of keys for resident entries. * Get the set of keys for resident entries.
* *
...@@ -537,19 +507,6 @@ public class CacheLIRS<K, V> implements Map<K, V> { ...@@ -537,19 +507,6 @@ public class CacheLIRS<K, V> implements Map<K, V> {
return set; return set;
} }
/**
* Get the collection of values.
*
* @return the collection of values
*/
public Collection<V> values() {
ArrayList<V> list = new ArrayList<V>();
for (K k : keySet()) {
list.add(get(k));
}
return list;
}
/** /**
* Get the entry set for all resident entries. * Get the entry set for all resident entries.
* *
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论