Package org.codehaus.groovy.runtime.metaclass

# Class ConcurrentReaderHashMap.HashIterator

java.lang.Object
org.codehaus.groovy.runtime.metaclass.ConcurrentReaderHashMap.HashIterator

All Implemented Interfaces:
  `Enumeration`, `Iterator`

Direct Known Subclasses:
  `ConcurrentReaderHashMap.KeyIterator`, `ConcurrentReaderHashMap.ValueIterator`

Enclosing class:
  ConcurrentReaderHashMap

protected class ConcurrentReaderHashMap.HashIterator extends Object implements Iterator, Enumeration

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Object`
  `currentKey`
  `protected Object`
  `currentValue`
  `protected ConcurrentReaderHashMap.Entry`
  `entry`
  `protected int`
  `index`
  `protected ConcurrentReaderHashMap.Entry`
  `lastReturned`
  `protected final ConcurrentReaderHashMap.Entry[]`
  `tab`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `HashIterator()`
  Constructs a new HashIterator over a snapshot of the table.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `hasMoreElements()`
  Returns whether there are more elements (Enumeration interface).
  `boolean`
  `hasNext()`
  Returns whether there are more elements to iterate over.
  `Object`
  `next()`
  Returns the next element in the iteration.
  `Object`
  `nextElement()`
  Returns the next element (Enumeration interface).
  `void`
  `remove()`
  Removes the last returned element from the map.
  `protected Object`
  `returnValueOfNext()`
  Returns the value of the next element.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.util.Enumeration

  `asIterator`

  ### Methods inherited from interface java.util.Iterator

  `forEachRemaining`

- ## Field Details

  - ### tab

    protected final ConcurrentReaderHashMap.Entry[] tab

  - ### index

    protected int index

  - ### entry

    protected ConcurrentReaderHashMap.Entry entry

  - ### currentKey

    protected Object currentKey

  - ### currentValue

    protected Object currentValue

  - ### lastReturned

    protected ConcurrentReaderHashMap.Entry lastReturned

- ## Constructor Details

  - ### HashIterator

    protected HashIterator()
    Constructs a new HashIterator over a snapshot of the table.

- ## Method Details

  - ### hasMoreElements

    public boolean hasMoreElements()
    Returns whether there are more elements (Enumeration interface).
    Specified by:
      `hasMoreElements` in interface `Enumeration`
    Returns:
      true if there are more elements, false otherwise

  - ### nextElement

    public Object nextElement()
    Returns the next element (Enumeration interface).
    Specified by:
      `nextElement` in interface `Enumeration`
    Returns:
      the next element
    Throws:
      `NoSuchElementException` - if there are no more elements

  - ### hasNext

    public boolean hasNext()
    Returns whether there are more elements to iterate over.
    Specified by:
      `hasNext` in interface `Iterator`
    Returns:
      true if there are more elements, false otherwise

  - ### returnValueOfNext

    protected Object returnValueOfNext()
    Returns the value of the next element. This method can be overridden by subclasses to return different values (e.g., just the key or just the value instead of the whole entry).
    Returns:
      the value to return for the next element

  - ### next

    public Object next()
    Returns the next element in the iteration.
    Specified by:
      `next` in interface `Iterator`
    Returns:
      the next element
    Throws:
      `NoSuchElementException` - if there are no more elements

  - ### remove

    public void remove()
    Removes the last returned element from the map.
    Specified by:
      `remove` in interface `Iterator`
    Throws:
      `IllegalStateException` - if next() has not been called or remove() has already been called after the last next() call