diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
| commit | d4ca769e542b2489b1e23cfcbdc3a0b7275b87cd (patch) | |
| tree | 1653a7399f97fb0c63ce62e3f60fd830d5c37f70 /base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java | |
| parent | 2ac2e31a56ae59ee582e43a90c3495f86dd9ee7a (diff) | |
Cleanup pass
Cleanup pass to uniformize things
Diffstat (limited to 'base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java | 29 |
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); |
