Java List Partition partitionList(List list, int folds)

Here you can find the source of partitionList(List list, int folds)

Description

partition List

License

Open Source License

Declaration

public static List[] partitionList(List list, int folds) 

Method Source Code

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

import java.util.List;

public class Main {
    public static List[] partitionList(List list, int folds) {
        List[] partitions = new List[folds];
        int partitionSize = list.size() / folds, index;
        for (int i = 0; i < folds; i++) {
            index = i * partitionSize;// w w w. j ava  2  s  . co  m
            partitions[i] = list.subList(index, i < folds - 1 ? index + partitionSize : list.size());
        } // for        
        return partitions;
    }
}

Related

  1. partition(List longList, int length)
  2. partition(List orig, int size)
  3. partition(List sourceList, int numberOfSegments)
  4. partitionIntoFolds( List values, int numFolds)
  5. partitionList(final List originalList, final int chunkSize)
  6. partitionList(List list, final int partitionSize)
  7. partitionVariable(List arr, int chunk)
  8. removePartition(List donorPartitionList, int partition)
  9. splitListByPartitionSize(List list, int partitionSize)