Class Partition<T>
- All Implemented Interfaces:
Iterable<List<T>>,Collection<List<T>>,List<List<T>>,SequencedCollection<List<T>>
Separates a given list into smaller chunks (partitions).
Useful if you want to bulk-process large amounts of data, but want to interrupt for a different task every X items.
Usage example:
Partition<String> lines = Partition.of(myHugeTextFileData, 500);
for (List<String> linesChunk : lines) { // gives you a list with up to 500 items
for (String line : linesChunk) {
// processing
}
updateUI(linesChunk.size());
}
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
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, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArray
-
Method Details
-
of
-
get
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein classAbstractCollection<List<T>>
-