Package io.microsphere.collection
Class SingletonIterator<E>
- java.lang.Object
-
- io.microsphere.collection.ReadOnlyIterator<E>
-
- io.microsphere.collection.SingletonIterator<E>
-
- Type Parameters:
E
- the type of the element returned by this iterator
- All Implemented Interfaces:
java.util.Iterator<E>
public class SingletonIterator<E> extends ReadOnlyIterator<E>
A specialized read-onlyIterator
implementation that iterates over a single element.This iterator is useful when you need to expose an
Iterator
interface for a single element, ensuring that the underlying element cannot be modified or removed during iteration due to its read-only nature.- Since:
- 1.0.0
- Author:
- Mercy
-
-
Constructor Summary
Constructors Constructor Description SingletonIterator(E element)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
forEachRemaining(java.util.function.Consumer<? super E> action)
boolean
hasNext()
E
next()
-
Methods inherited from class io.microsphere.collection.ReadOnlyIterator
remove
-
-