Class UnmodifiableIterator<E>
java.lang.Object
cloud.opencode.base.collections.UnmodifiableIterator<E>
- Type Parameters:
E- element type | 元素类型
- All Implemented Interfaces:
Iterator<E>
UnmodifiableIterator - Iterator that does not support remove operation
UnmodifiableIterator - 不支持删除操作的迭代器
An iterator that does not support the remove() operation. Any attempt
to call remove() will throw an UnsupportedOperationException.
不支持 remove() 操作的迭代器。任何调用 remove() 的尝试都会抛出
UnsupportedOperationException。
Features | 主要功能:
- Read-only iteration - 只读迭代
- Safe for immutable collections - 适用于不可变集合
Usage Examples | 使用示例:
UnmodifiableIterator<String> iterator = UnmodifiableIterator.of(list.iterator());
while (iterator.hasNext()) {
String element = iterator.next();
// iterator.remove() would throw UnsupportedOperationException
}
Performance | 性能特性:
- All operations: O(1) per call - 所有操作: 每次调用 O(1)
Security | 安全性:
- Thread-safe: Same as underlying iterator - 线程安全: 与底层迭代器相同
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor for subclasses. -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> UnmodifiableIterator<E> Create an unmodifiable iterator wrapping the given iterator.final voidremove()Remove operation is not supported.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining, hasNext, next
-
Constructor Details
-
UnmodifiableIterator
protected UnmodifiableIterator()Protected constructor for subclasses. 子类使用的保护构造方法。
-
-
Method Details
-
remove
public final void remove()Remove operation is not supported. 不支持删除操作。- Specified by:
removein interfaceIterator<E>- Throws:
UnsupportedOperationException- always | 总是抛出
-
of
Create an unmodifiable iterator wrapping the given iterator. 创建包装给定迭代器的不可修改迭代器。- Type Parameters:
E- element type | 元素类型- Parameters:
iterator- the iterator to wrap | 要包装的迭代器- Returns:
- unmodifiable iterator | 不可修改迭代器
-