| <html devsite="true"> |
| <head> |
| <title>LruCacheKt</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <div itemscope="" itemtype="http://developers.google.com/ReferenceObject"> |
| <meta itemprop="name" content="LruCacheKt"> |
| <meta itemprop="path" content="androidx.collection"> |
| <meta itemprop="property" content="lruCache(kotlin.Int,kotlin.Function2,kotlin.Function1,kotlin.Function4)"> |
| <meta itemprop="language" content="JAVA"> |
| </div> |
| <div id="header-block"> |
| <div> |
| <h1>LruCacheKt</h1> |
| </div> |
| </div> |
| <div id="refdoc-switcher-placeholder"></div> |
| <p> |
| <pre>public final class <a href="/reference/androidx/collection/LruCacheKt.html">LruCacheKt</a></pre> |
| </p> |
| <hr> |
| <h2>Summary</h2> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%"><h3>Public methods</h3></th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>static final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/collection/LruCache.html">LruCache</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> K, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V></code></td> |
| <td> |
| <div><code><K extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>, V extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/collection/LruCacheKt.html#lruCache(kotlin.Int,kotlin.Function2,kotlin.Function1,kotlin.Function4)">lruCache</a>(<br> int maxSize,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function2<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> value, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Integer.html">Integer</a>> sizeOf,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, V> create,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function4<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> oldValue, newValue, <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>> onEntryRemoved<br>)</code></div> |
| <p>Creates an <code><a href="/reference/androidx/collection/LruCache.html">LruCache</a></code> with the given parameters.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="list"> |
| <h2>Public methods</h2> |
| <div class="api-item"><a name="lruCache(kotlin.Int, kotlin.Function2, kotlin.Function1, kotlin.Function4)"></a><a name="lruCache-kotlin.Int-kotlin.Function2-kotlin.Function1-kotlin.Function4-"></a><a name="lrucache"></a> |
| <div class="api-name-block"> |
| <div> |
| <h3 id="lruCache(kotlin.Int,kotlin.Function2,kotlin.Function1,kotlin.Function4)">lruCache</h3> |
| </div> |
| </div> |
| <pre class="api-signature no-pretty-print">public static final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/collection/LruCache.html">LruCache</a><@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> K, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V> <K extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>, V extends <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/collection/LruCacheKt.html#lruCache(kotlin.Int,kotlin.Function2,kotlin.Function1,kotlin.Function4)">lruCache</a>(<br> int maxSize,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function2<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> value, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Integer.html">Integer</a>> sizeOf,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, V> create,<br> @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function4<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> oldValue, newValue, <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>> onEntryRemoved<br>)</pre> |
| <p>Creates an <code><a href="/reference/androidx/collection/LruCache.html">LruCache</a></code> with the given parameters.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">Parameters</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code>int maxSize</code></td> |
| <td> |
| <p>for caches that do not specify <code><a href="/reference/androidx/collection/package-summary.html#lruCache(kotlin.Int,kotlin.Function2,kotlin.Function1,kotlin.Function4)">sizeOf</a></code>, this is the maximum number of entries in the cache. For all other caches, this is the maximum sum of the sizes of the entries in this cache.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function2<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> value, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Integer.html">Integer</a>> sizeOf</code></td> |
| <td> |
| <p>function that returns the size of the entry for key and value in user-defined units. The default implementation returns 1.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, V> create</code></td> |
| <td> |
| <p>a create called after a cache miss to compute a value for the corresponding key. Returns the computed value or null if no value can be computed. The default implementation returns null.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function4<@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key, @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> oldValue, newValue, <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>> onEntryRemoved</code></td> |
| <td> |
| <p>a function called for entries that have been evicted or removed.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <colgroup> |
| <col width="40%"> |
| <col> |
| </colgroup> |
| <thead> |
| <tr> |
| <th colspan="100%">See also</th> |
| </tr> |
| </thead> |
| <tbody class="list"> |
| <tr> |
| <td><code><a href="/reference/androidx/collection/LruCache.html#sizeOf(kotlin.Any,kotlin.Any)">sizeOf</a></code></td> |
| <td></td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/collection/LruCache.html#create(kotlin.Any)">create</a></code></td> |
| <td></td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/androidx/collection/LruCache.html#entryRemoved(kotlin.Boolean,kotlin.Any,kotlin.Any,kotlin.Any)">entryRemoved</a></code></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </div> |
| </body> |
| </html> |