This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch feature_NUMBERS-215
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git


The following commit(s) were added to refs/heads/feature_NUMBERS-215 by this 
push:
     new feb37d3a NUMBERS-215: Iterate over k-partitions.
feb37d3a is described below

commit feb37d3a3aadda8eddebee9bb24476db6318b132
Author: Gilles Sadowski <[email protected]>
AuthorDate: Sat Sep 19 18:14:36 2026 +0200

    NUMBERS-215: Iterate over k-partitions.
    
    Remove "varargs" method.
---
 .../commons/numbers/combinatorics/Stirling.java    | 25 ++++------------------
 .../numbers/combinatorics/StirlingTest.java        | 20 -----------------
 2 files changed, 4 insertions(+), 41 deletions(-)

diff --git 
a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Stirling.java
 
b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Stirling.java
index 2fc8a4a4..faaa62c9 100644
--- 
a/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Stirling.java
+++ 
b/commons-numbers-combinatorics/src/main/java/org/apache/commons/numbers/combinatorics/Stirling.java
@@ -303,8 +303,10 @@ public final class Stirling {
             ((a >>> 1) * b) >>> 1;
     }
 
+    // CHECKSTYLE: stop regex
     /**
      * From a collection of {@code n} items, generates all partitions that 
contains {@code k} subsets.
+     *
      * For example:
      * <pre>{@code
      * Stirling.S2.of(4, 2)
@@ -333,6 +335,7 @@ public final class Stirling {
      * this element belongs in a given partition.
      * </p>
      */
+    // CHECKSTYLE: resume regex
     public static final class S2 {
         /** Number of sublists in every partition (aka "k"). */
         private final int numberOfSubsets;
@@ -418,8 +421,8 @@ public final class Stirling {
          * Factory method for iterating on the partitions of the given list
          * of {@code items}.
          *
-         * @param k Number of sublists in each partition.
          * @param items Items to be partitioned.
+         * @param k Number of sublists in each partition.
          * @return a stream (without duplicate or "null" elements).
          *
          * @param <T> Item type.
@@ -429,26 +432,6 @@ public final class Stirling {
             return of(items.size(), k).stream().map(o -> mapPartition(o, 
items, k));
         }
 
-        /**
-         * Iteration wrapped in a stream.
-         *
-         * @param items Items to be partitioned.
-         * @return a stream (without duplicate or "null" elements).
-         * @throws IllegalArgumentException if the number of {@code items} does
-         * not match the {@link #of(int,int) first argument of the factory 
method}.
-         *
-         * @param <T> Item type.
-         */
-        public <T> Stream<List<List<T>>> stream(T... items) {
-            if (items.length != numberOfElements) {
-                throw new 
CombinatoricsException(CombinatoricsException.MISMATCH,
-                                                 numberOfElements, 
items.length);
-            }
-
-            final List<T> list = Arrays.asList(items);
-            return stream().map(o -> mapPartition(o, list, numberOfSubsets));
-        }
-
         /**
          * Creates a partition generator that returns each partition as
          * indices between {@code 0} (included) and {@code n} (excluded).
diff --git 
a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/StirlingTest.java
 
b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/StirlingTest.java
index e53ae9a3..d6b49a41 100644
--- 
a/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/StirlingTest.java
+++ 
b/commons-numbers-combinatorics/src/test/java/org/apache/commons/numbers/combinatorics/StirlingTest.java
@@ -422,26 +422,6 @@ class StirlingTest {
         Assertions.assertEquals(c, part.get(1).get(1));
     }
 
-    @Test
-    void testS2ItemsStreamVarArgs() {
-        final int numPartitions = Stirling.S2.of(5, 2)
-            .stream("A", "B", "C", "D", "E")
-            .collect(Collectors.toList()).size();
-        Assertions.assertEquals(15, numPartitions);
-    }
-
-    @Test
-    void testS2ItemsStreamTooManyItems() {
-        Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> Stirling.S2.of(4, 2).stream("A", "B", 
"C", "D", "E"));
-    }
-
-    @Test
-    void testS2ItemsStreamTooFewItems() {
-        Assertions.assertThrows(IllegalArgumentException.class,
-                                () -> Stirling.S2.of(4, 2).stream("A", "B", 
"C"));
-    }
-
     @Test
     void testS2PartitionGenerationEmptyList() {
         Assertions.assertEquals(1, s2PartitionGenerator(0, 0).size());

Reply via email to