
com.magictools.core.collection.RandomAccessAvgPartition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of magic-tools-all Show documentation
Show all versions of magic-tools-all Show documentation
magic-tools 是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
The newest version!
package com.magictools.core.collection;
import java.util.List;
import java.util.RandomAccess;
/**
* 列表分区或分段(可随机访问列表)
* 通过传入分区个数,将指定列表分区为不同的块,每块区域的长度均匀分布(个数差不超过1)
*
* [1,2,3,4] -》 [1,2], [3, 4]
* [1,2,3,4] -》 [1,2], [3], [4]
* [1,2,3,4] -》 [1], [2], [3], [4]
* [1,2,3,4] -》 [1], [2], [3], [4], []
*
* 分区是在原List的基础上进行的,返回的分区是不可变的抽象列表,原列表元素变更,分区中元素也会变更。
*
* @param 元素类型
* @author looly
* @since 5.7.10
*/
public class RandomAccessAvgPartition extends AvgPartition implements RandomAccess {
/**
* 列表分区
*
* @param list 被分区的列表
* @param limit 分区个数
*/
public RandomAccessAvgPartition(List list, int limit) {
super(list, limit);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy