Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c1df35f authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

`LruCache` under Ravenwood.

Another common utility that is valuable, along with relevant tests.

Bug: 292141694
Test: atest CtsUtilTestCasesRavenwood:LruCacheTest CtsUtilTestCases:LruCacheTest
Change-Id: Ic2212518a61287fe1e4782075c8df20fed24f6d0
parent 299ea3e3
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.util;

import android.compat.annotation.UnsupportedAppUsage;

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

@@ -61,6 +62,7 @@ import java.util.Map;
 * of <a href="http://developer.android.com/sdk/compatibility-library.html">Android's
 * Support Package</a> for earlier releases.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class LruCache<K, V> {
    @UnsupportedAppUsage
    private final LinkedHashMap<K, V> map;
@@ -208,7 +210,7 @@ public class LruCache<K, V> {
                    break;
                }

                Map.Entry<K, V> toEvict = map.eldest();
                Map.Entry<K, V> toEvict = eldest();
                if (toEvict == null) {
                    break;
                }
@@ -224,6 +226,16 @@ public class LruCache<K, V> {
        }
    }

    @android.ravenwood.annotation.RavenwoodReplace
    private Map.Entry<K, V> eldest() {
        return map.eldest();
    }

    private Map.Entry<K, V> eldest$ravenwood() {
        final Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
        return it.hasNext() ? it.next() : null;
    }

    /**
     * Removes the entry for {@code key} if it exists.
     *
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ android.util.DataUnit
android.util.EventLog
android.util.IntArray
android.util.LongArray
android.util.LruCache
android.util.Slog
android.util.TimeUtils
android.util.Xml