Package com.google.common.cache
Class LocalCache.WriteQueue<K,V>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<ReferenceEntry<K,V>>
-
- com.google.common.cache.LocalCache.WriteQueue<K,V>
-
- All Implemented Interfaces:
java.lang.Iterable<ReferenceEntry<K,V>>,java.util.Collection<ReferenceEntry<K,V>>,java.util.Queue<ReferenceEntry<K,V>>
- Enclosing class:
- LocalCache<K,V>
static final class LocalCache.WriteQueue<K,V> extends java.util.AbstractQueue<ReferenceEntry<K,V>>
A custom queue for managing eviction order. Note that this is tightly integrated withReferenceEntry, upon which it relies to perform its linking.Note that this entire implementation makes the assumption that all elements which are in the map are also in this queue, and that all elements not in the queue are not in the map.
The benefits of creating our own queue are that (1) we can replace elements in the middle of the queue as part of copyWriteEntry, and (2) the contains method is highly optimized for the current model.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ReferenceEntry<K,V>head
-
Constructor Summary
Constructors Constructor Description WriteQueue()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontains(java.lang.Object o)booleanisEmpty()java.util.Iterator<ReferenceEntry<K,V>>iterator()booleanoffer(ReferenceEntry<K,V> entry)ReferenceEntry<K,V>peek()ReferenceEntry<K,V>poll()booleanremove(java.lang.Object o)intsize()-
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
head
final ReferenceEntry<K,V> head
-
-
Method Detail
-
offer
public boolean offer(ReferenceEntry<K,V> entry)
-
peek
public ReferenceEntry<K,V> peek()
-
poll
public ReferenceEntry<K,V> poll()
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
removein interfacejava.util.Collection<K>- Overrides:
removein classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfacejava.util.Collection<K>- Overrides:
containsin classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<K>- Overrides:
isEmptyin classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<K>- Specified by:
sizein classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<K>- Overrides:
clearin classjava.util.AbstractQueue<ReferenceEntry<K,V>>
-
iterator
public java.util.Iterator<ReferenceEntry<K,V>> iterator()
- Specified by:
iteratorin interfacejava.util.Collection<K>- Specified by:
iteratorin interfacejava.lang.Iterable<K>- Specified by:
iteratorin classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
-