修复Partition计算size除数为0报错问题

This commit is contained in:
Looly
2022-10-24 12:09:31 +08:00
parent 5c835ef888
commit 4c0d594e99
2 changed files with 6 additions and 1 deletions

View File

@@ -42,6 +42,10 @@ public class Partition<T> extends AbstractList<List<T>> {
public int size() {
// 此处采用动态计算以应对list变
final int size = this.size;
if(0 == size){
return 0;
}
final int total = list.size();
// 类似于判断余数当总数非整份size时多余的数>=1则相当于被除数多一个size做到+1目的
// 类似于if(total % size > 0){length += 1;}