summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-07-16 10:11:49 +0200
committergjoranv <gv@verizonmedia.com>2020-07-16 10:12:19 +0200
commit1eb5aeac9e1ad94f4e5d290cd57264541968454b (patch)
tree0db6722d283c5f5080a8a9dc81c0d6bfa5fea6b9 /vespajlib
parentc608c8384315cebdc8adacb012a8c49a09cc0340 (diff)
Reapply "Load platform bundles separately"
This reverts commit 0355cb740fe498abc03861bcb64de5e418c2fa88.
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/collections/PredicateSplit.java40
-rw-r--r--vespajlib/src/test/java/com/yahoo/collections/PredicateSplitTestCase.java30
2 files changed, 0 insertions, 70 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/collections/PredicateSplit.java b/vespajlib/src/main/java/com/yahoo/collections/PredicateSplit.java
deleted file mode 100644
index 1b3941df7bf..00000000000
--- a/vespajlib/src/main/java/com/yahoo/collections/PredicateSplit.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.collections;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.function.Predicate;
-
-/**
- * Class holding the result of a partition-by-predicate operation.
- **/
-public class PredicateSplit<E> {
- public final List<E> falseValues; /// list of values where the predicate returned false
- public final List<E> trueValues; /// list of values where the predicate returned true
-
- private PredicateSplit() {
- falseValues = new ArrayList<E>();
- trueValues = new ArrayList<E>();
- }
-
- /**
- * Perform a partition-by-predicate operation.
- * Each value in the input is tested by the predicate and
- * added to either the falseValues list or the trueValues list.
- * @param collection The input collection.
- * @param predicate A test for selecting the target list.
- * @return Two lists bundled in an object.
- **/
- public static <V> PredicateSplit<V> partition(Iterable<V> collection, Predicate<? super V> predicate)
- {
- PredicateSplit<V> r = new PredicateSplit<V>();
- for (V value : collection) {
- if (predicate.test(value)) {
- r.trueValues.add(value);
- } else {
- r.falseValues.add(value);
- }
- }
- return r;
- }
-}
diff --git a/vespajlib/src/test/java/com/yahoo/collections/PredicateSplitTestCase.java b/vespajlib/src/test/java/com/yahoo/collections/PredicateSplitTestCase.java
deleted file mode 100644
index 05a719d6a4d..00000000000
--- a/vespajlib/src/test/java/com/yahoo/collections/PredicateSplitTestCase.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.collections;
-
-import org.junit.Test;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import static org.junit.Assert.assertEquals;
-
-public class PredicateSplitTestCase {
- @Test
- public void requireThatSplitWorks() {
- List<Integer> l = new ArrayList<Integer>();
- l.add(1);
- l.add(6);
- l.add(2);
- l.add(4);
- l.add(5);
- PredicateSplit<Integer> result = PredicateSplit.partition(l, x -> (x % 2 == 0));
- assertEquals((long) result.falseValues.size(), 2L);
- assertEquals((long) result.falseValues.get(0), 1L);
- assertEquals((long) result.falseValues.get(1), 5L);
-
- assertEquals((long) result.trueValues.size(), 3L);
- assertEquals((long) result.trueValues.get(0), 6L);
- assertEquals((long) result.trueValues.get(1), 2L);
- assertEquals((long) result.trueValues.get(2), 4L);
- }
-}