Package org.rcsb.strucmotif.math
Class Partition<T>
- Type Parameters:
T- type of the original collection
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/
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionPartition(Collection<T> list, int chunkSize) Split a collection into partitions up to a defined size. -
Method Summary
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Constructor Details
-
Partition
Split a collection into partitions up to a defined size.- Parameters:
list- collection to partitionchunkSize- how many elements in one batch
-
-
Method Details