Package org.miaixz.bus.core.center.list
Class Partition<T>
- Type Parameters:
T- 元素类型
- All Implemented Interfaces:
Iterable<List<T>>,Collection<List<T>>,List<List<T>>,SequencedCollection<List<T>>
- Direct Known Subclasses:
AvgPartition,RandomAccessPartition
列表分区或分段
通过传入分区长度,将指定列表分区为不同的块,每块区域的长度相同(最后一块可能小于长度)
分区是在原List的基础上进行的,返回的分区是不可变的抽象列表,原列表元素变更,分区中元素也会变更。
参考:Guava的Lists#Partition
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescription被分区的列表protected final int每个分区的长度Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Field Details
-
list
被分区的列表 -
size
protected final int size每个分区的长度
-
-
Constructor Details
-
Partition
列表分区- Parameters:
list- 被分区的列表size- 每个分区的长度
-
-
Method Details
-
get
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein classAbstractCollection<List<T>>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceList<T>- Overrides:
isEmptyin classAbstractCollection<List<T>>
-