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 void
clear()
boolean
contains(java.lang.Object o)
boolean
isEmpty()
java.util.Iterator<ReferenceEntry<K,V>>
iterator()
boolean
offer(ReferenceEntry<K,V> entry)
ReferenceEntry<K,V>
peek()
ReferenceEntry<K,V>
poll()
boolean
remove(java.lang.Object o)
int
size()
-
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:
remove
in interfacejava.util.Collection<K>
- Overrides:
remove
in classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
contains
in interfacejava.util.Collection<K>
- Overrides:
contains
in classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Collection<K>
- Overrides:
isEmpty
in classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<K>
- Specified by:
size
in classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<K>
- Overrides:
clear
in classjava.util.AbstractQueue<ReferenceEntry<K,V>>
-
iterator
public java.util.Iterator<ReferenceEntry<K,V>> iterator()
- Specified by:
iterator
in interfacejava.util.Collection<K>
- Specified by:
iterator
in interfacejava.lang.Iterable<K>
- Specified by:
iterator
in classjava.util.AbstractCollection<ReferenceEntry<K,V>>
-
-