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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4374325  NUMBERS-166: removing BiConsumer implementation from 
SortInPlace
4374325 is described below

commit 437432572b9840ebf7b34efa5e0de35971a38f79
Author: Matt Juntunen <mattjuntu...@apache.org>
AuthorDate: Sat Jul 10 07:46:08 2021 -0400

    NUMBERS-166: removing BiConsumer implementation from SortInPlace
---
 .../org/apache/commons/numbers/arrays/SortInPlace.java   | 16 +++++++---------
 .../apache/commons/numbers/arrays/SortInPlaceTest.java   | 12 ++++++------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git 
a/commons-numbers-arrays/src/main/java/org/apache/commons/numbers/arrays/SortInPlace.java
 
b/commons-numbers-arrays/src/main/java/org/apache/commons/numbers/arrays/SortInPlace.java
index ee160a6..0e2eccf 100644
--- 
a/commons-numbers-arrays/src/main/java/org/apache/commons/numbers/arrays/SortInPlace.java
+++ 
b/commons-numbers-arrays/src/main/java/org/apache/commons/numbers/arrays/SortInPlace.java
@@ -17,12 +17,11 @@
 
 package org.apache.commons.numbers.arrays;
 
-import java.util.Comparator;
-import java.util.List;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Arrays;
-import java.util.function.BiConsumer;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
 
 /**
  * Sort an array and perform the same reordering of entries on other arrays.
@@ -32,14 +31,14 @@ import java.util.function.BiConsumer;
  *  <li>{@code y = [1, 2, 3]}</li>
  *  <li>{@code z = [0, 5, 7]}</li>
  * </ul>
- * then {@code Sort.ASCENDING.accept(x, y, z)} will update those arrays:
+ * then {@code Sort.ASCENDING.apply(x, y, z)} will update those arrays:
  * <ul>
  *  <li>{@code x = [1, 2, 3]}</li>
  *  <li>{@code y = [2, 3, 1]}</li>
  *  <li>{@code z = [5, 7, 0]}</li>
  * </ul>
  */
-public enum SortInPlace implements BiConsumer<double[], double[][]> {
+public enum SortInPlace {
     /** Sort in ascending order. */
     ASCENDING((o1, o2) -> Double.compare(o1.key(), o2.key())),
     /** Sort in descending order. */
@@ -64,9 +63,8 @@ public enum SortInPlace implements BiConsumer<double[], 
double[][]> {
      * those performed on {@code x}.
      * @throws IllegalArgumentException if not all arrays have the same size.
      */
-    @Override
-    public void accept(double[] x,
-                       double[]... yList) {
+    public void apply(double[] x,
+                      double[]... yList) {
         final int yListLen = yList.length;
         final int len = x.length;
 
diff --git 
a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SortInPlaceTest.java
 
b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SortInPlaceTest.java
index 7523608..30cc69c 100644
--- 
a/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SortInPlaceTest.java
+++ 
b/commons-numbers-arrays/src/test/java/org/apache/commons/numbers/arrays/SortInPlaceTest.java
@@ -31,7 +31,7 @@ class SortInPlaceTest {
         final double[] y = {4, 25, 9, 1, 16};
         final double[] z = {8, -125, 27, 1, 64};
 
-        SortInPlace.ASCENDING.accept(x, y, z);
+        SortInPlace.ASCENDING.apply(x, y, z);
 
         final double[] xE = {-3, 1, 2, 4, 5};
         final double[] yE = {9, 1, 4, 16, 25};
@@ -48,7 +48,7 @@ class SortInPlaceTest {
         final double[] y = {4, 25, 9, 1, 16};
         final double[] z = {8, -125, 27, 1, 64};
 
-        SortInPlace.DESCENDING.accept(x, y, z);
+        SortInPlace.DESCENDING.apply(x, y, z);
 
         final double[] xE = {5, 4, 2, 1, -3};
         final double[] yE = {25, 16, 4, 1, 9};
@@ -66,7 +66,7 @@ class SortInPlaceTest {
         final double[] y = {1, 2, 3};
         final double[] z = {0, 5, 7};
 
-        SortInPlace.ASCENDING.accept(x, y, z);
+        SortInPlace.ASCENDING.apply(x, y, z);
 
         final double[] xE = {1, 2, 3};
         final double[] yE = {2, 3, 1};
@@ -84,8 +84,8 @@ class SortInPlaceTest {
         final double[] two = {1, 2};
         final double[] onep = {2};
 
-        Assertions.assertThrows(IllegalArgumentException.class, () -> 
SortInPlace.ASCENDING.accept(one, two));
-        Assertions.assertThrows(NullPointerException.class, () -> 
SortInPlace.ASCENDING.accept(one, nullArray));
-        Assertions.assertThrows(NullPointerException.class, () -> 
SortInPlace.ASCENDING.accept(one, onep, nullArray));
+        Assertions.assertThrows(IllegalArgumentException.class, () -> 
SortInPlace.ASCENDING.apply(one, two));
+        Assertions.assertThrows(NullPointerException.class, () -> 
SortInPlace.ASCENDING.apply(one, nullArray));
+        Assertions.assertThrows(NullPointerException.class, () -> 
SortInPlace.ASCENDING.apply(one, onep, nullArray));
     }
 }

Reply via email to