mysql集合与集合的子集_大集合List分为多个子集合
importcom.duotin.util.beans.SubListView;importjava.util.ArrayList;importjava.util.Collections;importjava.util.List;/***
* Created by xueshan on 17/1/22.*/
public classCommonBusiLogic {/***將大集合分成多個子集合
*@paramlist
*@paramsubListSize 大小
*@param
*@return
*/
public static List> getSubListBySubListSize(Listlist, Integer subListSize){
List> allList = new ArrayList<>();if(CollectionUtils.isEmpty(list)){returnCollections.emptyList();
}if(list.size()<=subListSize){
allList.add(list);returnallList;
}for(SubListView subListView:getSubListViewList(list.size(), subListSize)){
allList.add(list.subList(subListView.getStartIndex(),subListView.getEndIndex()));
}returnallList;
}private static ListgetSubListViewList(Integer listSize, Integer subListSize){
List subListViewList = new ArrayList<>();
Integer multipleSize=listSize/subListSize;for(int i=0;i
SubListView subListView= newSubListView();
subListView.setStartIndex(i);
subListView.setEndIndex(i+subListSize);
subListView.setSubListSize(subListSize);
subListViewList.add(subListView);
}if(listSize%subListSize>0){
SubListView endSubListView= newSubListView();
endSubListView.setStartIndex(multipleSize*subListSize);
endSubListView.setEndIndex(multipleSize*subListSize+listSize%subListSize);
endSubListView.setSubListSize(subListSize);
subListViewList.add(endSubListView);
}returnsubListViewList;
}
}
總結
以上是生活随笔為你收集整理的mysql集合与集合的子集_大集合List分为多个子集合的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c++ vlc读取摄像头_Qt音视频开发
- 下一篇: mysql空间释放_linux 空间释放