blob: 2012e19bd74cd75f8969351f93328c79927c31ee [file]
<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&nbsp;final @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/collection/LruCache.html">LruCache</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> K,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V&gt;</code></td>
<td>
<div><code>&lt;K&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>,&nbsp;V&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/collection/LruCacheKt.html#lruCache(kotlin.Int,kotlin.Function2,kotlin.Function1,kotlin.Function4)">lruCache</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;maxSize,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function2&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> value,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Integer.html">Integer</a>&gt;&nbsp;sizeOf,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;V&gt;&nbsp;create,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function4&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> oldValue,&nbsp;newValue,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;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&nbsp;static&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/collection/LruCache.html">LruCache</a>&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> K,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> V&gt;&nbsp;&lt;K&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>,&nbsp;V&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/collection/LruCacheKt.html#lruCache(kotlin.Int,kotlin.Function2,kotlin.Function1,kotlin.Function4)">lruCache</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;maxSize,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function2&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> value,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Integer.html">Integer</a>&gt;&nbsp;sizeOf,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function1&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;V&gt;&nbsp;create,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Function4&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> oldValue,&nbsp;newValue,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;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&nbsp;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&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> value,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Integer.html">Integer</a>&gt;&nbsp;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&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;V&gt;&nbsp;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&lt;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> key,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> oldValue,&nbsp;newValue,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;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>