commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [3/5] [math] Use explicit constructor invocation ("this").
Date Sun, 15 May 2016 23:28:06 GMT
Use explicit constructor invocation ("this").


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/03380256
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/03380256
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/03380256

Branch: refs/heads/feature-MATH-1341
Commit: 03380256795725c7d17db97d882a4c4da3b76b8d
Parents: 412a8a0
Author: Gilles <erans@apache.org>
Authored: Sat May 14 01:03:54 2016 +0200
Committer: Gilles <erans@apache.org>
Committed: Sat May 14 14:20:14 2016 +0200

----------------------------------------------------------------------
 .../math4/stat/ranking/NaturalRanking.java      | 43 +++++++++-----------
 1 file changed, 19 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/03380256/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java b/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java
index d6efc09..d0c2ac2 100644
--- a/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java
+++ b/src/main/java/org/apache/commons/math4/stat/ranking/NaturalRanking.java
@@ -26,6 +26,7 @@ import org.apache.commons.math4.exception.MathInternalError;
 import org.apache.commons.math4.exception.NotANumberException;
 import org.apache.commons.math4.random.RandomDataGenerator;
 import org.apache.commons.math4.random.RandomGenerator;
+import org.apache.commons.math4.random.Well19937c;
 import org.apache.commons.math4.util.FastMath;
 
 
@@ -88,10 +89,7 @@ public class NaturalRanking implements RankingAlgorithm {
      * Create a NaturalRanking with default strategies for handling ties and NaNs.
      */
     public NaturalRanking() {
-        super();
-        tiesStrategy = DEFAULT_TIES_STRATEGY;
-        nanStrategy = DEFAULT_NAN_STRATEGY;
-        randomData = null;
+        this(DEFAULT_NAN_STRATEGY, DEFAULT_TIES_STRATEGY, null);
     }
 
     /**
@@ -100,10 +98,7 @@ public class NaturalRanking implements RankingAlgorithm {
      * @param tiesStrategy the TiesStrategy to use
      */
     public NaturalRanking(TiesStrategy tiesStrategy) {
-        super();
-        this.tiesStrategy = tiesStrategy;
-        nanStrategy = DEFAULT_NAN_STRATEGY;
-        randomData = new RandomDataGenerator();
+        this(DEFAULT_NAN_STRATEGY, tiesStrategy, new Well19937c());
     }
 
     /**
@@ -112,10 +107,7 @@ public class NaturalRanking implements RankingAlgorithm {
      * @param nanStrategy the NaNStrategy to use
      */
     public NaturalRanking(NaNStrategy nanStrategy) {
-        super();
-        this.nanStrategy = nanStrategy;
-        tiesStrategy = DEFAULT_TIES_STRATEGY;
-        randomData = null;
+        this(nanStrategy, DEFAULT_TIES_STRATEGY, null);
     }
 
     /**
@@ -125,10 +117,7 @@ public class NaturalRanking implements RankingAlgorithm {
      * @param tiesStrategy TiesStrategy to use
      */
     public NaturalRanking(NaNStrategy nanStrategy, TiesStrategy tiesStrategy) {
-        super();
-        this.nanStrategy = nanStrategy;
-        this.tiesStrategy = tiesStrategy;
-        randomData = new RandomDataGenerator();
+        this(nanStrategy, tiesStrategy, new Well19937c());
     }
 
     /**
@@ -138,13 +127,9 @@ public class NaturalRanking implements RankingAlgorithm {
      * @param randomGenerator source of random data
      */
     public NaturalRanking(RandomGenerator randomGenerator) {
-        super();
-        this.tiesStrategy = TiesStrategy.RANDOM;
-        nanStrategy = DEFAULT_NAN_STRATEGY;
-        randomData = new RandomDataGenerator(randomGenerator);
+        this(DEFAULT_NAN_STRATEGY, TiesStrategy.RANDOM, randomGenerator);
     }
 
-
     /**
      * Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM
      * and the given source of random data.
@@ -153,10 +138,20 @@ public class NaturalRanking implements RankingAlgorithm {
      * @param randomGenerator source of random data
      */
     public NaturalRanking(NaNStrategy nanStrategy,
-            RandomGenerator randomGenerator) {
-        super();
+                          RandomGenerator randomGenerator) {
+        this(nanStrategy, TiesStrategy.RANDOM, randomGenerator);
+    }
+
+    /**
+     * @param nanStrategy NaN strategy.
+     * @param randomGenerator RNG.
+     * @param tiesStrategy Tie strategy.
+     */
+    private NaturalRanking(NaNStrategy nanStrategy,
+                           TiesStrategy tiesStrategy,
+                           RandomGenerator randomGenerator) {
         this.nanStrategy = nanStrategy;
-        this.tiesStrategy = TiesStrategy.RANDOM;
+        this.tiesStrategy = tiesStrategy;
         randomData = new RandomDataGenerator(randomGenerator);
     }
 


Mime
View raw message