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
FieldsModifier and TypeFieldDescriptionprotected Objectprotected Objectprotected ConcurrentReaderHashMap.Entryprotected intprotected ConcurrentReaderHashMap.Entryprotected final ConcurrentReaderHashMap.Entry[] -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new HashIterator over a snapshot of the table. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether there are more elements (Enumeration interface).booleanhasNext()Returns whether there are more elements to iterate over.next()Returns the next element in the iteration.Returns the next element (Enumeration interface).voidremove()Removes the last returned element from the map.protected ObjectReturns the value of the next element.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Enumeration
asIteratorMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
tab
-
index
protected int index -
entry
-
currentKey
-
currentValue
-
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:
hasMoreElementsin interfaceEnumeration- Returns:
- true if there are more elements, false otherwise
-
nextElement
Returns the next element (Enumeration interface).- Specified by:
nextElementin interfaceEnumeration- 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. -
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
Returns the next element in the iteration.- Specified by:
nextin interfaceIterator- 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:
removein interfaceIterator- Throws:
IllegalStateException- if next() has not been called or remove() has already been called after the last next() call
-