Class OpenList
java.lang.Object
cloud.opencode.base.collections.OpenList
OpenList - List Facade Utility Class
OpenList - 列表门面工具类
Provides comprehensive list operations including creation, transformation, filtering, and searching.
提供全面的列表操作,包括创建、转换、过滤和搜索。
Features | 主要功能:
- Factory methods for list creation - 列表创建工厂方法
- List transformation - 列表转换
- List filtering - 列表过滤
- List searching - 列表搜索
- List partitioning - 列表分区
Usage Examples | 使用示例:
// Create list - 创建列表
List<String> list = OpenList.of("a", "b", "c");
// Reverse - 反转
List<String> reversed = OpenList.reverse(list);
// Partition - 分区
List<List<String>> partitions = OpenList.partition(list, 2);
// Transform - 转换
List<Integer> lengths = OpenList.transform(list, String::length);
Performance | 性能特性:
- Most operations: O(n) - 大多数操作: O(n)
- Random access: O(1) - 随机访问: O(1)
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncartesianProduct(List<? extends E>... lists) Compute Cartesian product of lists.cartesianProduct(List<? extends List<? extends E>> lists) Compute Cartesian product of lists.charactersOf(String string) Return a view of the string as a list of characters.static <E> List<E> Find all elements matching the predicate.static <E> Optional<E> Find the first element matching the predicate.static <E> ArrayList<E> Create an ArrayList from an Iterable.static <E> EGet the first element of the list.static <E> EGet the first element of the list with default value.static <E> EGet the last element of the list.static <E> EGet the last element of the list with default value.static <E> LinkedList<E> linkedListFrom(Iterable<? extends E> elements) Create a LinkedList from an Iterable.static <E> ArrayList<E> Create an empty ArrayList.static <E> LinkedList<E> Create a LinkedList.static <E> ArrayList<E> of(E... elements) Create an ArrayList with the given elements.Return a partition view of the list.static <E> List<E> Return a reversed view of the list.static <F,T> List <T> Return a transformed view of the list.static <E> ArrayList<E> withCapacity(int capacity) Create an ArrayList with initial capacity.
-
Method Details
-
newArrayList
Create an empty ArrayList. 创建空的 ArrayList。- Type Parameters:
E- element type | 元素类型- Returns:
- new empty ArrayList | 新的空 ArrayList
-
of
Create an ArrayList with the given elements. 创建包含给定元素的 ArrayList。- Type Parameters:
E- element type | 元素类型- Parameters:
elements- the elements | 元素- Returns:
- new ArrayList | 新的 ArrayList
-
from
-
withCapacity
Create an ArrayList with initial capacity. 创建具有初始容量的 ArrayList。- Type Parameters:
E- element type | 元素类型- Parameters:
capacity- initial capacity | 初始容量- Returns:
- new ArrayList | 新的 ArrayList
-
newLinkedList
Create a LinkedList. 创建 LinkedList。- Type Parameters:
E- element type | 元素类型- Returns:
- new LinkedList | 新的 LinkedList
-
linkedListFrom
Create a LinkedList from an Iterable. 从 Iterable 创建 LinkedList。- Type Parameters:
E- element type | 元素类型- Parameters:
elements- the elements | 元素- Returns:
- new LinkedList | 新的 LinkedList
-
reverse
-
partition
-
transform
Return a transformed view of the list. 返回列表的转换视图。- Type Parameters:
F- input element type | 输入元素类型T- output element type | 输出元素类型- Parameters:
list- the list | 列表function- the transform function | 转换函数- Returns:
- transformed list | 转换后的列表
-
charactersOf
-
getFirst
Get the first element of the list. 获取列表的第一个元素。- Type Parameters:
E- element type | 元素类型- Parameters:
list- the list | 列表- Returns:
- first element or null if empty | 第一个元素,空列表返回 null
-
getFirst
Get the first element of the list with default value. 获取列表的第一个元素,带默认值。- Type Parameters:
E- element type | 元素类型- Parameters:
list- the list | 列表defaultValue- default value | 默认值- Returns:
- first element or default | 第一个元素或默认值
-
getLast
Get the last element of the list. 获取列表的最后一个元素。- Type Parameters:
E- element type | 元素类型- Parameters:
list- the list | 列表- Returns:
- last element or null if empty | 最后一个元素,空列表返回 null
-
getLast
Get the last element of the list with default value. 获取列表的最后一个元素,带默认值。- Type Parameters:
E- element type | 元素类型- Parameters:
list- the list | 列表defaultValue- default value | 默认值- Returns:
- last element or default | 最后一个元素或默认值
-
findFirst
Find the first element matching the predicate. 查找第一个匹配谓词的元素。- Type Parameters:
E- element type | 元素类型- Parameters:
list- the list | 列表predicate- the predicate | 谓词- Returns:
- Optional containing the element or empty | 包含元素的 Optional 或空
-
filter
-
cartesianProduct
Compute Cartesian product of lists. 计算列表的笛卡尔积。- Type Parameters:
E- element type | 元素类型- Parameters:
lists- the lists | 列表- Returns:
- Cartesian product | 笛卡尔积
-
cartesianProduct
-