Record Class PersistentList.Nil<E>
java.lang.Object
java.lang.Record
cloud.opencode.base.collections.immutable.PersistentList.Nil<E>
- Type Parameters:
E- element type | 元素类型
- All Implemented Interfaces:
PersistentList<E>
- Enclosing interface:
PersistentList<E>
Nil - The empty persistent list.
Nil - 空的持久化列表。
- Since:
- JDK 25, opencode-base-collections V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
-
Nested Class Summary
Nested classes/interfaces inherited from interface PersistentList
PersistentList.Cons<E>, PersistentList.Nil<E> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppend an element to the end of this list (O(n)).booleanCheck if this list contains the given element.final booleanIndicates whether some other object is "equal to" this one.Filter elements by a predicate and return a new list (O(n)).final inthashCode()Returns a hash code value for this object.head()Return the head (first element) of this list (O(1)).booleanisEmpty()Check if this list is empty.iterator()Return an iterator over the elements.<R> PersistentList<R> Apply a function to each element and return a new list (O(n)).Prepend an element to the front of this list (O(1)).reversed()Return a reversed copy of this list (O(n)).intsize()Return the number of elements in this list.stream()Return a sequential stream over the elements.tail()Return the tail of this list (all elements except the first) (O(1)).toList()Convert this persistent list to a JDKList.toString()Returns a string representation of this record class.
-
Constructor Details
-
Nil
public Nil()Creates an instance of aNilrecord class.
-
-
Method Details
-
prepend
Description copied from interface:PersistentListPrepend an element to the front of this list (O(1)). 在列表前端插入一个元素 (O(1))。- Specified by:
prependin interfacePersistentList<E>- Parameters:
element- the element to prepend | 要前插的元素- Returns:
- a new list with the element prepended | 前插元素后的新列表
-
append
Description copied from interface:PersistentListAppend an element to the end of this list (O(n)). 在列表末尾追加一个元素 (O(n))。- Specified by:
appendin interfacePersistentList<E>- Parameters:
element- the element to append | 要追加的元素- Returns:
- a new list with the element appended | 追加元素后的新列表
-
tail
Description copied from interface:PersistentListReturn the tail of this list (all elements except the first) (O(1)). 返回列表的尾部(除第一个元素外的所有元素)(O(1))。- Specified by:
tailin interfacePersistentList<E>- Returns:
- the tail of the list | 列表的尾部
-
head
Description copied from interface:PersistentListReturn the head (first element) of this list (O(1)). 返回列表的头部(第一个元素)(O(1))。- Specified by:
headin interfacePersistentList<E>- Returns:
- the head element | 头部元素
-
size
public int size()Description copied from interface:PersistentListReturn the number of elements in this list. 返回列表中的元素数量。- Specified by:
sizein interfacePersistentList<E>- Returns:
- the size | 大小
-
isEmpty
public boolean isEmpty()Description copied from interface:PersistentListCheck if this list is empty. 检查列表是否为空。- Specified by:
isEmptyin interfacePersistentList<E>- Returns:
- true if the list is empty | 如果列表为空则返回 true
-
contains
Description copied from interface:PersistentListCheck if this list contains the given element. 检查列表是否包含给定元素。- Specified by:
containsin interfacePersistentList<E>- Parameters:
element- the element to search for | 要搜索的元素- Returns:
- true if the element is found | 如果找到元素则返回 true
-
reversed
Description copied from interface:PersistentListReturn a reversed copy of this list (O(n)). 返回此列表的反转副本 (O(n))。- Specified by:
reversedin interfacePersistentList<E>- Returns:
- reversed list | 反转后的列表
-
map
Description copied from interface:PersistentListApply a function to each element and return a new list (O(n)). 对每个元素应用函数并返回新列表 (O(n))。- Specified by:
mapin interfacePersistentList<E>- Type Parameters:
R- result element type | 结果元素类型- Parameters:
fn- the mapping function | 映射函数- Returns:
- a new list with mapped elements | 包含映射元素的新列表
-
filter
Description copied from interface:PersistentListFilter elements by a predicate and return a new list (O(n)). 按谓词过滤元素并返回新列表 (O(n))。- Specified by:
filterin interfacePersistentList<E>- Parameters:
predicate- the filter predicate | 过滤谓词- Returns:
- a new list with only matching elements | 仅包含匹配元素的新列表
-
toList
Description copied from interface:PersistentList- Specified by:
toListin interfacePersistentList<E>- Returns:
- an unmodifiable list containing all elements | 包含所有元素的不可修改列表
-
stream
Description copied from interface:PersistentListReturn a sequential stream over the elements. 返回元素上的顺序流。- Specified by:
streamin interfacePersistentList<E>- Returns:
- a stream | 流
-
iterator
Description copied from interface:PersistentListReturn an iterator over the elements. 返回元素上的迭代器。- Specified by:
iteratorin interfacePersistentList<E>- Returns:
- an iterator | 迭代器
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal.
-