Merge "Remove deprecated and unused entryEvicted method." into honeycomb-mr1
This commit is contained in:
@@ -207176,21 +207176,6 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
<method name="entryEvicted"
|
|
||||||
return="void"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="deprecated"
|
|
||||||
visibility="protected"
|
|
||||||
>
|
|
||||||
<parameter name="key" type="K">
|
|
||||||
</parameter>
|
|
||||||
<parameter name="value" type="V">
|
|
||||||
</parameter>
|
|
||||||
</method>
|
|
||||||
<method name="entryRemoved"
|
<method name="entryRemoved"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -267319,7 +267304,7 @@
|
|||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
<parameter name="t" type="T">
|
<parameter name="arg0" type="T">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
@@ -139,8 +139,7 @@ public class LruCache<K, V> {
|
|||||||
* Caches {@code value} for {@code key}. The value is moved to the head of
|
* Caches {@code value} for {@code key}. The value is moved to the head of
|
||||||
* the queue.
|
* the queue.
|
||||||
*
|
*
|
||||||
* @return the previous value mapped by {@code key}. Although that entry is
|
* @return the previous value mapped by {@code key}.
|
||||||
* no longer cached, it has not been passed to {@link #entryEvicted}.
|
|
||||||
*/
|
*/
|
||||||
public final V put(K key, V value) {
|
public final V put(K key, V value) {
|
||||||
if (key == null || value == null) {
|
if (key == null || value == null) {
|
||||||
@@ -195,15 +194,14 @@ public class LruCache<K, V> {
|
|||||||
evictionCount++;
|
evictionCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
entryEvicted(key, value);
|
entryRemoved(true, key, value, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the entry for {@code key} if it exists.
|
* Removes the entry for {@code key} if it exists.
|
||||||
*
|
*
|
||||||
* @return the previous value mapped by {@code key}. Although that entry is
|
* @return the previous value mapped by {@code key}.
|
||||||
* no longer cached, it has not been passed to {@link #entryEvicted}.
|
|
||||||
*/
|
*/
|
||||||
public final V remove(K key) {
|
public final V remove(K key) {
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
@@ -225,16 +223,6 @@ public class LruCache<K, V> {
|
|||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls {@link #entryRemoved}.
|
|
||||||
*
|
|
||||||
* @deprecated replaced by entryRemoved
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
protected void entryEvicted(K key, V value) {
|
|
||||||
entryRemoved(true, key, value, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for entries that have been evicted or removed. This method is
|
* Called for entries that have been evicted or removed. This method is
|
||||||
* invoked when a value is evicted to make space, removed by a call to
|
* invoked when a value is evicted to make space, removed by a call to
|
||||||
@@ -291,7 +279,7 @@ public class LruCache<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the cache, calling {@link #entryEvicted} on each removed entry.
|
* Clear the cache, calling {@link #entryRemoved} on each removed entry.
|
||||||
*/
|
*/
|
||||||
public final void evictAll() {
|
public final void evictAll() {
|
||||||
trimToSize(-1); // -1 will evict 0-sized elements
|
trimToSize(-1); // -1 will evict 0-sized elements
|
||||||
|
|||||||
@@ -183,20 +183,15 @@ public final class LruCacheTest extends TestCase {
|
|||||||
* Replacing the value for a key doesn't cause an eviction but it does bring
|
* Replacing the value for a key doesn't cause an eviction but it does bring
|
||||||
* the replaced entry to the front of the queue.
|
* the replaced entry to the front of the queue.
|
||||||
*/
|
*/
|
||||||
public void testPutDoesNotCauseEviction() {
|
public void testPutCauseEviction() {
|
||||||
final List<String> evictionLog = new ArrayList<String>();
|
List<String> log = new ArrayList<String>();
|
||||||
List<String> expectedEvictionLog = new ArrayList<String>();
|
LruCache<String, String> cache = newRemovalLogCache(log);
|
||||||
LruCache<String, String> cache = new LruCache<String, String>(3) {
|
|
||||||
@Override protected void entryEvicted(String key, String value) {
|
|
||||||
evictionLog.add(key + "=" + value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
cache.put("a", "A");
|
cache.put("a", "A");
|
||||||
cache.put("b", "B");
|
cache.put("b", "B");
|
||||||
cache.put("c", "C");
|
cache.put("c", "C");
|
||||||
cache.put("b", "B2");
|
cache.put("b", "B2");
|
||||||
assertEquals(expectedEvictionLog, evictionLog);
|
assertEquals(Arrays.asList("b=B>B2"), log);
|
||||||
assertSnapshot(cache, "a", "A", "c", "C", "b", "B2");
|
assertSnapshot(cache, "a", "A", "c", "C", "b", "B2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user