summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java')
-rw-r--r--base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java b/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
index 455fbf8..681d707 100644
--- a/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
+++ b/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
@@ -12,7 +12,7 @@ import bjc.funcdata.IList;
* @author ben
*
* @param <E>
- * The type of element in the list being partitioned
+ * The type of element in the list being partitioned
*/
final class GroupPartIteration<E> implements Consumer<E> {
/* The list we're returning. */
@@ -35,21 +35,21 @@ final class GroupPartIteration<E> implements Consumer<E> {
* Create a new group partitioning iteration.
*
* @param returned
- * The list containing all of the existing partitions.
+ * The list containing all of the existing partitions.
*
* @param rejects
- * The items that have been rejected from a partition for being
- * too large.
+ * The items that have been rejected from a partition for being
+ * too large.
*
* @param nPerPart
- * The combined value of items that should go into each
- * partition.
+ * The combined value of items that should go into each
+ * partition.
*
* @param eleCount
- * The function to use to determine the value of an item.
+ * The function to use to determine the value of an item.
*/
- public GroupPartIteration(final IList<IList<E>> returned, final IList<E> rejects, final int nPerPart,
- final Function<E, Integer> eleCount) {
+ public GroupPartIteration(final IList<IList<E>> returned, final IList<E> rejects,
+ final int nPerPart, final Function<E, Integer> eleCount) {
this.returnedList = returned;
this.rejectedItems = rejects;
this.numberPerPartition = nPerPart;
@@ -61,9 +61,10 @@ final class GroupPartIteration<E> implements Consumer<E> {
@Override
public void accept(final E value) {
- final boolean shouldStartPartition = numberInCurrentPartition >= numberPerPartition;
+ final boolean shouldStartPartition
+ = numberInCurrentPartition >= numberPerPartition;
- if(shouldStartPartition) {
+ if (shouldStartPartition) {
returnedList.add(currentPartition);
currentPartition = new FunctionalList<>();
@@ -71,10 +72,10 @@ final class GroupPartIteration<E> implements Consumer<E> {
} else {
final int currentElementCount = elementCounter.apply(value);
- final boolean shouldReject = (numberInCurrentPartition
- + currentElementCount) >= numberPerPartition;
+ final boolean shouldReject = (numberInCurrentPartition + currentElementCount)
+ >= numberPerPartition;
- if(shouldReject) {
+ if (shouldReject) {
rejectedItems.add(value);
} else {
currentPartition.add(value);