package com.srs.comprehensive.util;

import org.apache.poi.ss.formula.functions.T;

import java.util.ArrayList;
import java.util.List;

/**
 * list切割工具类
 */
public class ListSliceUtil {
    public static <T> List<List<T>> updateSlice(List<T> list){
        if (list.size()==0){
            return null;
        }
        int userListSize=list.size();
        int sum=userListSize/1000;
        int sums=userListSize%1000;
        if (sums!=0){
            sum++;
        }
        List<List<T>> listList=new ArrayList<>();
        int sumIm=0;
        for (int i=0;i<sum;i++){
            List<T> objects = new ArrayList<>();
            int listSum=1000;
            if (sums!=0&&i==sum-1){
                listSum=sums;
            }
            for (int j=0;j<listSum;j++){
                objects.add(list.get(sumIm));
                sumIm++;
            }
            listList.add(objects);
        }
        return listList;
    }
}
