Class 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 with ReferenceEntry, 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.AbstractQueue

        add, addAll, element, remove
      • 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
      • Methods inherited from interface java.util.Collection

        containsAll, equals, hashCode, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Constructor Detail

      • WriteQueue

        WriteQueue()
    • Method Detail

      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<K>
        Overrides:
        remove in class java.util.AbstractCollection<ReferenceEntry<K,​V>>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<K>
        Overrides:
        contains in class java.util.AbstractCollection<ReferenceEntry<K,​V>>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<K>
        Overrides:
        isEmpty in class java.util.AbstractCollection<ReferenceEntry<K,​V>>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<K>
        Specified by:
        size in class java.util.AbstractCollection<ReferenceEntry<K,​V>>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<K>
        Overrides:
        clear in class java.util.AbstractQueue<ReferenceEntry<K,​V>>
      • iterator

        public java.util.Iterator<ReferenceEntry<K,​V>> iterator()
        Specified by:
        iterator in interface java.util.Collection<K>
        Specified by:
        iterator in interface java.lang.Iterable<K>
        Specified by:
        iterator in class java.util.AbstractCollection<ReferenceEntry<K,​V>>