Java List Partition partition(List all, int partitionSize)

Here you can find the source of partition(List all, int partitionSize)

Description

partition

License

Open Source License

Declaration

public static List<List<Long>> partition(List<Long> all, int partitionSize) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static List<List<Long>> partition(List<Long> all, int partitionSize) {
        List<List<Long>> partitions = new ArrayList<>();
        final int count = all.size();
        for (int i = 0; i < count; i += partitionSize) {
            partitions.add(new ArrayList<>(all.subList(i, Math.min(count, i + partitionSize))));
        }/*from ww  w.j  a  v  a2s  .c  o m*/
        return partitions;
    }
}

Related

  1. partition(final List items, final int size)
  2. partition(final List list, final int length)
  3. partition(List list, Integer batchSize)
  4. partition(List a, int lower, int upper)
  5. partition(List items, int slices)
  6. partition(List list, int num)
  7. partition(List list, int partitionSize)