Class Partition<T>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<List<T>>
org.rcsb.strucmotif.math.Partition<T>
Type Parameters:
T - type of the original collection
All Implemented Interfaces:
Iterable<List<T>>, Collection<List<T>>, List<List<T>>

public class Partition<T> extends AbstractList<List<T>>
Partitions a collection into (roughly) equal-sized chunks. Will shuffle the original collection. code from: https://e.printstacktrace.blog/divide-a-list-to-lists-of-n-size-in-Java-8/
  • Constructor Details

    • Partition

      public Partition(Collection<T> list, int chunkSize)
      Split a collection into partitions up to a defined size.
      Parameters:
      list - collection to partition
      chunkSize - how many elements in one batch
  • Method Details