diff options
author | 2017-04-10 15:02:13 +0000 | |
---|---|---|
committer | 2017-04-11 10:49:52 +0200 | |
commit | a3cf662f26feddfff671c41eb876fd63c3f5a232 (patch) | |
tree | 91ea07093d15e0832159b410d18500dc4e1fe307 /src/main/java/com/google/devtools/build/lib/util | |
parent | e835a3f037e83fb4abb85a3eb5c2fe653a219477 (diff) |
Allow constructing a dependency group with an initial capacity in GroupedListHelper
RELNOTES: None
PiperOrigin-RevId: 152687516
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/util')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/util/GroupedList.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/util/GroupedList.java b/src/main/java/com/google/devtools/build/lib/util/GroupedList.java index 9babacff2b..5fe983899e 100644 --- a/src/main/java/com/google/devtools/build/lib/util/GroupedList.java +++ b/src/main/java/com/google/devtools/build/lib/util/GroupedList.java @@ -432,6 +432,16 @@ public class GroupedList<T> implements Iterable<Collection<T>> { currentGroup = new ArrayList<>(); } + /** + * Starts a group with an initial capacity. All elements added until {@link #endGroup} will be + * in the same group. Each call of startGroup must be paired with a following {@link #endGroup} + * call. Any duplicate elements added to this group will be silently deduplicated. + */ + public void startGroup(int expectedGroupSize) { + Preconditions.checkState(currentGroup == null, this); + currentGroup = new ArrayList<>(expectedGroupSize); + } + /** Ends a group started with {@link #startGroup}. */ public void endGroup() { Preconditions.checkNotNull(currentGroup); |