Class ConcurrentEntryIterator<K,​V>

  • All Implemented Interfaces:
    Iterator<Entry<K,​V>>

    public class ConcurrentEntryIterator<K,​V>
    extends Object
    implements Iterator<Entry<K,​V>>
    Iterator over all cache entries.

    Hash expansion: During the iteration a hash expansion may happen, which means every entry is rehashed. In this case it is most likely that entries are missed. If an expansion occurred, the iteration will restart from the beginning. To ensure that every entry is only iterated once, the iterator has an internal bookkeeping, what was previously iterated.

    Clear: A clear operation stops current iterations.

    Close: A close operation will stop the iteration and yield a CacheClosedException

    Author:
    Jens Wilke
    • Constructor Detail

      • ConcurrentEntryIterator

        public ConcurrentEntryIterator​(HeapCache<K,​V> cache)
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<K>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<K>
      • hasBeenIterated

        public boolean hasBeenIterated​(K key,
                                       int hashCode)
        Used by the storage code to filter out already iterated keys
      • markIterated

        public void markIterated​(K key,
                                 int hashCode)
        Mark the key as returned by the iteration to suppress doubled iterations when we need to scan throw twice ore more, e.g. in case of a hash table expansion.
        Parameters:
        key - key object
        hashCode - corresponding modified hash, unused but we keep it if we want to switch to a more efficient hash table