Class SetView<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
cloud.opencode.base.collections.SetView<E>
- Type Parameters:
E- element type | 元素类型
- All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>
SetView - Abstract Set View for Lazy Set Operations
SetView - 惰性集合运算的抽象集合视图
Provides a read-only view of set operations without creating new collections. The actual computation is deferred until iteration.
提供集合运算结果的只读视图,不创建新集合。实际计算延迟到迭代时。
Features | 主要功能:
- Lazy computation - 惰性计算
- Read-only view - 只读视图
- Copy to mutable/immutable collections - 复制到可变/不可变集合
Usage Examples | 使用示例:
// Union view - 并集视图
SetView<String> union = SetUtil.union(set1, set2);
// Copy to new HashSet - 复制到新 HashSet
Set<String> copy = union.copyInto(new HashSet<>());
Performance | 性能特性:
- Creation: O(1) - 创建: O(1)
- Iteration: O(n) - 迭代: O(n)
- contains(): varies by operation - contains(): 因操作而异
Security | 安全性:
- Thread-safe: No (depends on underlying sets) - 线程安全: 否(取决于底层集合)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfinal booleanThis operation is not supported on SetView SetView 不支持添加操作final voidclear()This operation is not supported on SetView SetView 不支持清空操作copyInto(S set) Copy this view into the specified set 复制到指定集合final booleanThis operation is not supported on SetView SetView 不支持移除操作toSet()Copy this view to a new HashSet 复制到新的 HashSetMethods inherited from class AbstractSet
equals, hashCode, removeAllMethods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, iterator, retainAll, size, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
copyInto
-
toSet
-
add
This operation is not supported on SetView SetView 不支持添加操作- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classAbstractCollection<E>- Parameters:
e- element to add | 要添加的元素- Returns:
- never returns | 永不返回
- Throws:
UnsupportedOperationException- always | 总是抛出
-
remove
This operation is not supported on SetView SetView 不支持移除操作- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classAbstractCollection<E>- Parameters:
o- element to remove | 要移除的元素- Returns:
- never returns | 永不返回
- Throws:
UnsupportedOperationException- always | 总是抛出
-
clear
public final void clear()This operation is not supported on SetView SetView 不支持清空操作- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classAbstractCollection<E>- Throws:
UnsupportedOperationException- always | 总是抛出
-