summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-10-11 22:49:16 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-10-11 22:49:16 -0300
commit8923edffdb36b790014ff47301e53f7ede93ea0d (patch)
treee1cff9168eb79110a8832249d208f2978f549a04 /base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
parent946cab444bc301d8a7c756a1bab039558288de89 (diff)
Cleanup more
Diffstat (limited to 'base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java')
-rw-r--r--base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java38
1 files changed, 30 insertions, 8 deletions
diff --git a/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java b/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
index f3b2254..9e4b43a 100644
--- a/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
+++ b/base/src/main/java/bjc/utils/funcutils/GroupPartIteration.java
@@ -7,24 +7,46 @@ import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
/**
- * Implements a single group partitioning pass on a list
+ * Implements a single group partitioning pass on a list.
*
* @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. */
private final IList<IList<E>> returnedList;
- public IList<E> currentPartition;
- private final IList<E> rejectedItems;
+ /* The current partition of the list. */
+ public IList<E> currentPartition;
+ /* The items rejected from the current partition. */
+ private final IList<E> rejectedItems;
- private int numberInCurrentPartition;
- private final int numberPerPartition;
+ /* The number of items in the current partition. */
+ private int numberInCurrentPartition;
+ /* The number of items in each partition. */
+ private final int numberPerPartition;
+ /* The function to use to count an item. */
private final Function<E, Integer> elementCounter;
+ /**
+ * Create a new group partitioning iteration.
+ *
+ * @param returned
+ * The list containing all of the existing partitions.
+ *
+ * @param rejects
+ * 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.
+ *
+ * @param eleCount
+ * 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) {
this.returnedList = returned;
@@ -48,8 +70,8 @@ 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) {
rejectedItems.add(value);