public class FixSizeLRUCache<K,V> extends Object implements Cache<K,V>
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
FixSizeLRUCache.E<K,V> |
Cache.Entry<K,V>| 限定符和类型 | 方法和说明 |
|---|---|
void |
clear()
Removes all the mappings from this cache (optional operation).
|
static <K,V> FixSizeLRUCache<K,V> |
create() |
static <K,V> FixSizeLRUCache<K,V> |
create(int size) |
void |
forEach(Consumer<? super Cache.Entry<K,V>> action)
Performs the given action for each element of the
Iterable
until all elements have been processed or the action throws an
exception. |
V |
get(K k)
Returns the value to which the specified key is mapped,
or
null if this cache contains no mapping for the key. |
Iterator<Cache.Entry<K,V>> |
iterator()
Returns an iterator over elements of type
Cache.Entry<K, V>. |
void |
put(K k,
V v)
Associates the specified value with the specified key in this cache.
|
protected FixSizeLRUCache.E<K,V> |
remove()
Remove the last item
|
V |
remove(K k)
Removes the mapping for a key from this cache if it is present
(optional operation).
|
int |
size()
Returns the number of key-value mappings in this cache.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitspliteratorpublic static <K,V> FixSizeLRUCache<K,V> create()
public static <K,V> FixSizeLRUCache<K,V> create(int size)
public V get(K k)
null if this cache contains no mapping for the key.public void put(K k, V v)
public V remove(K k)
protected FixSizeLRUCache.E<K,V> remove()
public void clear()
public int size()
public Iterator<Cache.Entry<K,V>> iterator()
Cache.Entry<K, V>.iterator 在接口中 Iterable<Cache.Entry<K,V>>public void forEach(Consumer<? super Cache.Entry<K,V>> action)
Iterable
until all elements have been processed or the action throws an
exception. Unless otherwise specified by the implementing class,
actions are performed in the order of iteration (if an iteration order
is specified). Exceptions thrown by the action are relayed to the
caller.
The default implementation behaves as if:
for (T t : this)
action.accept(t);
forEach 在接口中 Iterable<Cache.Entry<K,V>>action - The action to be performed for each elementNullPointerException - if the specified action is nullCopyright © 2025. All rights reserved.