Java List Sub List subList(List src, int preBatchCount)

Here you can find the source of subList(List src, int preBatchCount)

Description

sub List

License

Apache License

Declaration

public static <T> List<T>[] subList(List<T> src, int preBatchCount) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static <T> List<T>[] subList(List<T> src, int preBatchCount) {
        int count = src.size();
        int batchCount = (count + preBatchCount - 1) / preBatchCount;
        List[] result = new List[batchCount];

        for (int index = 0; index < batchCount; ++index) {
            int begin = index * preBatchCount;
            int end = (index + 1) * preBatchCount;
            if (end > count) {
                end = count;//from   w w  w . jav a  2s.c o m
            }

            result[index] = src.subList(begin, end);
        }

        return result;
    }
}

Related

  1. subList(List list, int start, int max)
  2. subList(List list, int[] indexs)
  3. subList(List origin, int start, int length)
  4. subList(List parentList, int start, int end)
  5. subList(List query, int first, int max)
  6. subList(List list, int start, int end)
  7. subListByStartAndEnd( List list, M start, M end)
  8. subListMaxSize(List list, int maxSize)
  9. subListPage(List baseList, int fromIndex, int maxPageSize)