commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r657612 - in /commons/proper/math/branches/MATH_2_0/src: java/org/apache/commons/math/estimation/ java/org/apache/commons/math/fraction/ java/org/apache/commons/math/ode/ java/org/apache/commons/math/optimization/ java/org/apache/commons/ma...
Date Sun, 18 May 2008 19:37:23 GMT
Author: luc
Date: Sun May 18 12:37:23 2008
New Revision: 657612

URL: http://svn.apache.org/viewvc?rev=657612&view=rev
Log:
Replaced Raw types by Parameterized types where appropriate.
The various ArrayList, HashSet and HashMap used in math have
be restricted to the content they are intended for.
This removes lots of warnings that have appeared after the
switch to Java 5, and improves safety (for example the categories
used by OneWayAnova are guaranteed to be double arrays at compile
time).
Two difficult cases where not handled here: the Frequency class
and the Fitness interface. The first one mixes types and needs to
be studied before any change is attempted. The second one generates
some side effects on the overall package which is still under development.

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/SwitchingFunctionsHandler.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistribution.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomData.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomDataImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnova.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/TestUtils.java
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/TransformerMap.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/RandomDataTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/OneWayAnovaTest.java
    commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/estimation/SimpleEstimationProblem.java Sun May 18 12:37:23 2008
@@ -18,7 +18,6 @@
 package org.apache.commons.math.estimation;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -46,8 +45,8 @@
      * Build an empty instance without parameters nor measurements.
      */
     public SimpleEstimationProblem() {
-        parameters   = new ArrayList();
-        measurements = new ArrayList();
+        parameters   = new ArrayList<EstimatedParameter>();
+        measurements = new ArrayList<WeightedMeasurement>();
     }
 
     /** 
@@ -65,9 +64,8 @@
     public EstimatedParameter[] getUnboundParameters() {
 
         // filter the unbound parameters
-        List unbound = new ArrayList(parameters.size());
-        for (Iterator iterator = parameters.iterator(); iterator.hasNext();) {
-            EstimatedParameter p = (EstimatedParameter) iterator.next();
+        List<EstimatedParameter> unbound = new ArrayList<EstimatedParameter>(parameters.size());
+        for (EstimatedParameter p : parameters) {
             if (! p.isBound()) {
                 unbound.add(p);
             }
@@ -102,9 +100,9 @@
     }
 
     /** Estimated parameters. */
-    private final List parameters;
+    private final List<EstimatedParameter> parameters;
 
     /** Measurements. */
-    private final List measurements;
+    private final List<WeightedMeasurement> measurements;
 
 }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/fraction/Fraction.java Sun May 18 12:37:23 2008
@@ -25,7 +25,7 @@
  * @since 1.1
  * @version $Revision$ $Date$
  */
-public class Fraction extends Number implements Comparable {
+public class Fraction extends Number implements Comparable<Fraction> {
 
     /** A fraction representing "1 / 1". */
     public static final Fraction ONE = new Fraction(1, 1);
@@ -34,7 +34,7 @@
     public static final Fraction ZERO = new Fraction(0, 1);
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = -8958519416450949235L;
+    private static final long serialVersionUID = -5731055832688548463L;
     
     /** The denominator. */
     private final int denominator;
@@ -246,13 +246,12 @@
      * @return -1 if this is less than <tt>object</tt>, +1 if this is greater
      *         than <tt>object</tt>, 0 if they are equal.
      */
-    public int compareTo(Object object) {
+    public int compareTo(Fraction object) {
         int ret = 0;
         
         if (this != object) { 
-            Fraction other = (Fraction)object;
             double first = doubleValue();
-            double second = other.doubleValue();
+            double second = object.doubleValue();
             
             if (first < second) {
                 ret = -1;

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/AdaptiveStepsizeIntegrator.java Sun May 18 12:37:23 2008
@@ -163,7 +163,7 @@
                                    double maxCheckInterval,
                                    double convergence,
                                    int maxIterationCount) {
-    switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
+    switchesHandler.addSwitchingFunction(function, maxCheckInterval, convergence, maxIterationCount);
   }
 
   /** Get all the switching functions that have been added to the integrator.
@@ -171,7 +171,7 @@
    * @see #addSwitchingFunction(SwitchingFunction, double, double, int)
    * @see #clearSwitchingFunctions()
    */
-  public Collection getSwitchingFunctions() {
+  public Collection<SwitchState> getSwitchingFunctions() {
       return switchesHandler.getSwitchingFunctions();
   }
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ContinuousOutputModel.java Sun May 18 12:37:23 2008
@@ -18,7 +18,6 @@
 package org.apache.commons.math.ode;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.io.Serializable;
 
@@ -45,14 +44,14 @@
  * get the model value at any time or to navigate through the
  * data).</p>
  *
- * <p>If problem modelization is done with several separate
+ * <p>If problem modeling is done with several separate
  * integration phases for contiguous intervals, the same
  * ContinuousOutputModel can be used as step handler for all
  * integration phases as long as they are performed in order and in
  * the same direction. As an example, one can extrapolate the
  * trajectory of a satellite with one model (i.e. one set of
  * differential equations) up to the beginning of a maneuver, use
- * another more complex model including thrusters modelization and
+ * another more complex model including thrusters modeling and
  * accurate attitude control during the maneuver, and revert to the
  * first model after the end of the maneuver. If the same continuous
  * output model handles the steps of all integration phases, the user
@@ -86,7 +85,7 @@
    * Build an empty continuous output model.
    */
   public ContinuousOutputModel() {
-    steps = new ArrayList();
+    steps = new ArrayList<StepInterpolator>();
     reset();
   }
 
@@ -129,8 +128,8 @@
 
     }
 
-    for (Iterator iter = model.steps.iterator(); iter.hasNext(); ) {
-      steps.add(((AbstractStepInterpolator) iter.next()).copy());
+    for (StepInterpolator interpolator : model.steps) {
+      steps.add(interpolator.copy());
     }
 
     index = steps.size() - 1;
@@ -171,17 +170,15 @@
   public void handleStep(StepInterpolator interpolator, boolean isLast)
     throws DerivativeException {
 
-    AbstractStepInterpolator ai = (AbstractStepInterpolator) interpolator;
-
     if (steps.size() == 0) {
       initialTime = interpolator.getPreviousTime();
       forward     = interpolator.isForward();
     }
 
-    steps.add(ai.copy());
+    steps.add(interpolator.copy());
 
     if (isLast) {
-      finalTime = ai.getCurrentTime();
+      finalTime = interpolator.getCurrentTime();
       index     = steps.size() - 1;
     }
 
@@ -210,7 +207,7 @@
    * @return interpolation point time
    */
   public double getInterpolatedTime() {
-    return ((StepInterpolator) steps.get(index)).getInterpolatedTime();
+    return steps.get(index).getInterpolatedTime();
   }
     
   /** Set the time of the interpolated point.
@@ -230,11 +227,11 @@
     try {
       // initialize the search with the complete steps table
       int iMin = 0;
-      StepInterpolator sMin = (StepInterpolator) steps.get(iMin);
+      StepInterpolator sMin = steps.get(iMin);
       double tMin = 0.5 * (sMin.getPreviousTime() + sMin.getCurrentTime());
 
       int iMax = steps.size() - 1;
-      StepInterpolator sMax = (StepInterpolator) steps.get(iMax);
+      StepInterpolator sMax = steps.get(iMax);
       double tMax = 0.5 * (sMax.getPreviousTime() + sMax.getCurrentTime());
 
       // handle points outside of the integration interval
@@ -254,7 +251,7 @@
       while (iMax - iMin > 5) {
 
         // use the last estimated index as the splitting index
-        StepInterpolator si = (StepInterpolator) steps.get(index);
+        StepInterpolator si = steps.get(index);
         int location = locatePoint(time, si);
         if (location < 0) {
           iMax = index;
@@ -270,7 +267,7 @@
 
         // compute a new estimate of the index in the reduced table slice
         int iMed = (iMin + iMax) / 2;
-        StepInterpolator sMed = (StepInterpolator) steps.get(iMed);
+        StepInterpolator sMed = steps.get(iMed);
         double tMed = 0.5 * (sMed.getPreviousTime() + sMed.getCurrentTime());
 
         if ((Math.abs(tMed - tMin) < 1e-6) || (Math.abs(tMax - tMed) < 1e-6)) {
@@ -306,14 +303,11 @@
 
       // now the table slice is very small, we perform an iterative search
       index = iMin;
-      while ((index <= iMax) &&
-             (locatePoint(time, (StepInterpolator) steps.get(index)) > 0)) {
+      while ((index <= iMax) && (locatePoint(time, steps.get(index)) > 0)) {
         ++index;
       }
 
-      StepInterpolator si = (StepInterpolator) steps.get(index);
-
-      si.setInterpolatedTime(time);
+      steps.get(index).setInterpolatedTime(time);
 
     } catch (DerivativeException de) {
       throw new RuntimeException("unexpected DerivativeException caught: " +
@@ -327,7 +321,7 @@
    * @return state vector at time {@link #getInterpolatedTime}
    */
   public double[] getInterpolatedState() {
-    return ((StepInterpolator) steps.get(index)).getInterpolatedState();
+    return steps.get(index).getInterpolatedState();
   }
 
   /** Compare a step interval and a double. 
@@ -369,9 +363,9 @@
   private int index;
 
   /** Steps table. */
-  private List steps;
+  private List<StepInterpolator> steps;
 
   /** Serializable version identifier */
-  private static final long serialVersionUID = 2259286184268533249L;
+  private static final long serialVersionUID = -1417964919405031606L;
 
 }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/FirstOrderIntegrator.java Sun May 18 12:37:23 2008
@@ -74,7 +74,7 @@
    * @see #addSwitchingFunction(SwitchingFunction, double, double, int)
    * @see #clearSwitchingFunctions()
    */
-  public Collection getSwitchingFunctions();
+  public Collection<SwitchState> getSwitchingFunctions();
 
   /** Remove all the switching functions that have been added to the integrator.
    * @see #addSwitchingFunction(SwitchingFunction, double, double, int)

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/RungeKuttaIntegrator.java Sun May 18 12:37:23 2008
@@ -105,7 +105,7 @@
                                    double maxCheckInterval,
                                    double convergence,
                                    int maxIterationCount) {
-    switchesHandler.add(function, maxCheckInterval, convergence, maxIterationCount);
+    switchesHandler.addSwitchingFunction(function, maxCheckInterval, convergence, maxIterationCount);
   }
 
   /** Get all the switching functions that have been added to the integrator.
@@ -113,7 +113,7 @@
    * @see #addSwitchingFunction(SwitchingFunction, double, double, int)
    * @see #clearSwitchingFunctions()
    */
-  public Collection getSwitchingFunctions() {
+  public Collection<SwitchState> getSwitchingFunctions() {
       return switchesHandler.getSwitchingFunctions();
   }
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/SwitchingFunctionsHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/SwitchingFunctionsHandler.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/SwitchingFunctionsHandler.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/SwitchingFunctionsHandler.java Sun May 18 12:37:23 2008
@@ -20,7 +20,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.math.ConvergenceException;
@@ -39,7 +38,7 @@
    * Create an empty handler
    */
   public SwitchingFunctionsHandler() {
-    functions   = new ArrayList();
+    functions   = new ArrayList<SwitchState>();
     first       = null;
     initialized = false;
   }
@@ -55,23 +54,23 @@
    * @see #getSwitchingFunctions()
    * @see #clearSwitchingFunctions()
    */
-  public void add(SwitchingFunction function, double maxCheckInterval,
-                  double convergence, int maxIterationCount) {
+  public void addSwitchingFunction(SwitchingFunction function, double maxCheckInterval,
+                                   double convergence, int maxIterationCount) {
     functions.add(new SwitchState(function, maxCheckInterval,
                                   convergence, maxIterationCount));
   }
 
   /** Get all the switching functions that have been added to the handler.
    * @return an unmodifiable collection of the added switching functions
-   * @see #add(SwitchingFunction, double, double, int)
+   * @see #addSwitchingFunction(SwitchingFunction, double, double, int)
    * @see #clearSwitchingFunctions()
    */
-  public Collection getSwitchingFunctions() {
+  public Collection<SwitchState> getSwitchingFunctions() {
       return Collections.unmodifiableCollection(functions);
   }
 
   /** Remove all the switching functions that have been added to the handler.
-   * @see #add(SwitchingFunction, double, double, int)
+   * @see #addSwitchingFunction(SwitchingFunction, double, double, int)
    * @see #getSwitchingFunctions()
    */
   public void clearSwitchingFunctions() {
@@ -114,8 +113,8 @@
         double t0 = interpolator.getPreviousTime();
         interpolator.setInterpolatedTime(t0);
         double [] y = interpolator.getInterpolatedState();
-        for (Iterator iter = functions.iterator(); iter.hasNext();) {
-          ((SwitchState) iter.next()).reinitializeBegin(t0, y);
+        for (SwitchState state : functions) {
+          state.reinitializeBegin(t0, y);
         }
 
         initialized = true;
@@ -123,9 +122,8 @@
       }
 
       // check events occurrence
-      for (Iterator iter = functions.iterator(); iter.hasNext();) {
+      for (SwitchState state : functions) {
 
-        SwitchState state = (SwitchState) iter.next();
         if (state.evaluateStep(interpolator)) {
           if (first == null) {
             first = state;
@@ -176,8 +174,8 @@
   public void stepAccepted(double t, double[] y)
     throws IntegratorException {
     try {
-      for (Iterator iter = functions.iterator(); iter.hasNext();) {
-        ((SwitchState) iter.next()).stepAccepted(t, y);
+      for (SwitchState state : functions) {
+        state.stepAccepted(t, y);
       }
     } catch (SwitchException se) {
       throw new IntegratorException(se);
@@ -189,8 +187,8 @@
    * @return true if the integration should be stopped
    */
   public boolean stop() {
-    for (Iterator iter = functions.iterator(); iter.hasNext();) {
-      if (((SwitchState) iter.next()).stop()) {
+    for (SwitchState state : functions) {
+      if (state.stop()) {
         return true;
       }
     }
@@ -209,8 +207,8 @@
   public boolean reset(double t, double[] y) throws IntegratorException {
       try {
           boolean resetDerivatives = false;
-          for (Iterator iter = functions.iterator(); iter.hasNext();) {
-              if (((SwitchState) iter.next()).reset(t, y)) {
+          for (SwitchState state : functions) {
+              if (state.reset(t, y)) {
                   resetDerivatives = true;
               }
           }
@@ -221,7 +219,7 @@
   }
 
   /** Switching functions. */
-  private List functions;
+  private List<SwitchState> functions;
 
   /** First active switching function. */
   private SwitchState first;

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/optimization/DirectSearchOptimizer.java Sun May 18 12:37:23 2008
@@ -571,16 +571,15 @@
     }
 
     /** Comparator for {@link PointCostPair PointCostPair} objects. */
-    private static Comparator pointCostPairComparator = new Comparator() {
-        public int compare(Object o1, Object o2) {
+    private static Comparator<PointCostPair> pointCostPairComparator =
+        new Comparator<PointCostPair>() {
+        public int compare(PointCostPair o1, PointCostPair o2) {
             if (o1 == null) {
                 return (o2 == null) ? 0 : +1;
             } else if (o2 == null) {
                 return -1;
             }
-            double cost1 = ((PointCostPair) o1).getCost();
-            double cost2 = ((PointCostPair) o2).getCost();
-            return (cost1 < cost2) ? -1 : ((o1 == o2) ? 0 : +1);
+            return (o1.getCost() < o2.getCost()) ? -1 : ((o1 == o2) ? 0 : +1);
         }
     };
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistribution.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistribution.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistribution.java Sun May 18 12:37:23 2008
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import org.apache.commons.math.stat.descriptive.StatisticalSummary;
+import org.apache.commons.math.stat.descriptive.SummaryStatistics;
 
 /**
  * Represents an <a href="http://random.mat.sbg.ac.at/~ste/dipl/node11.html">
@@ -118,7 +119,7 @@
      * 
      * @return List of bin statistics
      */
-    List getBinStats();
+    List<SummaryStatistics> getBinStats();
 
     /**
      * Returns the array of upper bounds for the bins.  Bins are: <br/>

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java Sun May 18 12:37:23 2008
@@ -61,10 +61,10 @@
 public class EmpiricalDistributionImpl implements Serializable, EmpiricalDistribution {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = -6773236347582113490L;
+    private static final long serialVersionUID = 5729073523949762654L;
 
     /** List of SummaryStatistics objects characterizing the bins */
-    private List binStats = null;
+    private List<SummaryStatistics> binStats = null;
 
     /** Sample statistics */
     private SummaryStatistics sampleStats = null;
@@ -85,7 +85,7 @@
      * Creates a new EmpiricalDistribution with the default bin count.
      */
     public EmpiricalDistributionImpl() {
-        binStats = new ArrayList();
+        binStats = new ArrayList<SummaryStatistics>();
     }
 
     /**
@@ -95,7 +95,7 @@
      */
     public EmpiricalDistributionImpl(int binCount) {
         this.binCount = binCount;
-        binStats = new ArrayList();
+        binStats = new ArrayList<SummaryStatistics>();
     }
 
      /**
@@ -254,8 +254,7 @@
             double val = 0.0d;
             while ((str = inputStream.readLine()) != null) {
                 val = Double.parseDouble(str);
-                SummaryStatistics stats =
-                    (SummaryStatistics) binStats.get(findBin(min, val, delta));
+                SummaryStatistics stats = binStats.get(findBin(min, val, delta));
                 stats.addValue(val);
             }
 
@@ -319,8 +318,7 @@
             throws IOException {
             for (int i = 0; i < inputArray.length; i++) {
                 SummaryStatistics stats =
-                    (SummaryStatistics) binStats.get(
-                            findBin(min, inputArray[i], delta));
+                    binStats.get(findBin(min, inputArray[i], delta));
                 stats.addValue(inputArray[i]);
             }
         }
@@ -369,12 +367,10 @@
         // Assign upperBounds based on bin counts
         upperBounds = new double[binCount];
         upperBounds[0] =
-        ((double)((SummaryStatistics)binStats.get(0)).getN())/
-        (double)sampleStats.getN();
+        ((double) binStats.get(0).getN()) / (double) sampleStats.getN();
         for (int i = 1; i < binCount-1; i++) {
             upperBounds[i] = upperBounds[i-1] +
-            ((double)((SummaryStatistics)binStats.get(i)).getN())/
-            (double)sampleStats.getN();
+            ((double) binStats.get(i).getN()) / (double) sampleStats.getN();
         }
         upperBounds[binCount-1] = 1.0d;
     }
@@ -411,7 +407,7 @@
         // Use this to select the bin and generate a Gaussian within the bin
         for (int i = 0; i < binCount; i++) {
            if (x <= upperBounds[i]) {
-               SummaryStatistics stats = (SummaryStatistics)binStats.get(i);
+               SummaryStatistics stats = binStats.get(i);
                if (stats.getN() > 0) {
                    if (stats.getStandardDeviation() > 0) {  // more than one obs
                         return randomData.nextGaussian
@@ -453,7 +449,7 @@
      * 
      * @return List of bin statistics.
      */
-    public List getBinStats() {
+    public List<SummaryStatistics> getBinStats() {
         return binStats;
     }
 

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomData.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomData.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomData.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomData.java Sun May 18 12:37:23 2008
@@ -268,5 +268,5 @@
      * @param k size of the sample
      * @return random sample of k elements from c
      */
-    Object[] nextSample(Collection c, int k);
+    Object[] nextSample(Collection<?> c, int k);
 }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomDataImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomDataImpl.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomDataImpl.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/RandomDataImpl.java Sun May 18 12:37:23 2008
@@ -545,7 +545,7 @@
      * @param k sample size.
      * @return the random sample.
      */
-    public Object[] nextSample(Collection c, int k) {
+    public Object[] nextSample(Collection<?> c, int k) {
         int len = c.size();
         if (k > len) {
             throw new IllegalArgumentException

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnova.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnova.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnova.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnova.java Sun May 18 12:37:23 2008
@@ -50,7 +50,7 @@
      * @throws MathException if the statistic can not be computed do to a
      *         convergence or other numerical error.
      */
-    public double anovaFValue(Collection categoryData)
+    public double anovaFValue(Collection<double[]> categoryData)
         throws IllegalArgumentException, MathException;
 
     /**
@@ -71,7 +71,7 @@
      * @throws MathException if the statistic can not be computed do to a
      *         convergence or other numerical error.
      */
-    public double anovaPValue(Collection categoryData)
+    public double anovaPValue(Collection<double[]> categoryData)
         throws IllegalArgumentException, MathException;
 
     /**
@@ -96,7 +96,7 @@
      * @throws MathException if the statistic can not be computed do to a
      *         convergence or other numerical error.
     */
-    public boolean anovaTest(Collection categoryData, double alpha)
+    public boolean anovaTest(Collection<double[]> categoryData, double alpha)
         throws IllegalArgumentException, MathException;
 
 }
\ No newline at end of file

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java Sun May 18 12:37:23 2008
@@ -16,15 +16,13 @@
  */
 package org.apache.commons.math.stat.inference;
 
-import org.apache.commons.math.MathException;
-import org.apache.commons.math.stat.descriptive.summary.Sum;
-import org.apache.commons.math.stat.descriptive.summary.SumOfSquares;
+import java.util.Collection;
 
+import org.apache.commons.math.MathException;
 import org.apache.commons.math.distribution.FDistribution;
 import org.apache.commons.math.distribution.FDistributionImpl;
-
-import java.util.Collection;
-import java.util.Iterator;
+import org.apache.commons.math.stat.descriptive.summary.Sum;
+import org.apache.commons.math.stat.descriptive.summary.SumOfSquares;
 
 
 /**
@@ -65,7 +63,7 @@
      * are as defined <a href="http://faculty.vassar.edu/lowry/ch13pt1.html">
      * here</a></p>
      */
-    public double anovaFValue(Collection categoryData)
+    public double anovaFValue(Collection<double[]> categoryData)
         throws IllegalArgumentException, MathException {
         AnovaStats a = anovaStats(categoryData);
         return a.F;
@@ -81,7 +79,7 @@
      * where <code>F</code> is the F value and <code>cumulativeProbability</code>
      * is the commons-math implementation of the F distribution.</p>
      */
-    public double anovaPValue(Collection categoryData)
+    public double anovaPValue(Collection<double[]> categoryData)
         throws IllegalArgumentException, MathException {
         AnovaStats a = anovaStats(categoryData);
         FDistribution fdist = new FDistributionImpl(a.dfbg, a.dfwg);
@@ -99,7 +97,7 @@
      * is the commons-math implementation of the F distribution.</p>
      * <p>True is returned iff the estimated p-value is less than alpha.</p>
      */
-    public boolean anovaTest(Collection categoryData, double alpha)
+    public boolean anovaTest(Collection<double[]> categoryData, double alpha)
         throws IllegalArgumentException, MathException {
         if ((alpha <= 0) || (alpha > 0.5)) {
             throw new IllegalArgumentException("bad significance level: " + alpha);
@@ -118,7 +116,7 @@
      * preconditions specified in the interface definition
      * @throws MathException if an error occurs computing the Anova stats
      */
-    private AnovaStats anovaStats(Collection categoryData)
+    private AnovaStats anovaStats(Collection<double[]> categoryData)
         throws IllegalArgumentException, MathException {
 
         // check if we have enough categories
@@ -128,14 +126,7 @@
         }
         
         // check if each category has enough data and all is double[]
-        for (Iterator iterator = categoryData.iterator(); iterator.hasNext();) {
-            double[] array;
-            try {
-                array = (double[])iterator.next();
-            } catch (ClassCastException ex) {
-                throw new IllegalArgumentException(
-                        "ANOVA: categoryData contains non-double[] elements.");
-            }
+        for (double[] array : categoryData) {
             if (array.length <= 1) {
                 throw new IllegalArgumentException(
                         "ANOVA: one element of categoryData has fewer than 2 values.");
@@ -148,8 +139,7 @@
         SumOfSquares totsumsq = new SumOfSquares();
         int totnum = 0;
         
-        for (Iterator iterator = categoryData.iterator(); iterator.hasNext();) {
-            double[] data = (double[])iterator.next();
+        for (double[] data : categoryData) {
 
             Sum sum = new Sum();
             SumOfSquares sumsq = new SumOfSquares();

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/TestUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/TestUtils.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/TestUtils.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/stat/inference/TestUtils.java Sun May 18 12:37:23 2008
@@ -382,7 +382,7 @@
      *
      * @since 1.2
      */
-    public static double oneWayAnovaFValue(Collection categoryData)
+    public static double oneWayAnovaFValue(Collection<double[]> categoryData)
     throws IllegalArgumentException, MathException {
         return oneWayAnova.anovaFValue(categoryData);
     }
@@ -392,7 +392,7 @@
      * 
      * @since 1.2
      */
-    public static double oneWayAnovaPValue(Collection categoryData)
+    public static double oneWayAnovaPValue(Collection<double[]> categoryData)
     throws IllegalArgumentException, MathException {
         return oneWayAnova.anovaPValue(categoryData);
     }
@@ -402,7 +402,7 @@
      *
      * @since 1.2
      */
-    public static boolean oneWayAnovaTest(Collection categoryData, double alpha)
+    public static boolean oneWayAnovaTest(Collection<double[]> categoryData, double alpha)
     throws IllegalArgumentException, MathException {
         return oneWayAnova.anovaTest(categoryData, alpha);
     }

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/TransformerMap.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/TransformerMap.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/TransformerMap.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/util/TransformerMap.java Sun May 18 12:37:23 2008
@@ -34,8 +34,8 @@
 public class TransformerMap implements NumberTransformer, Serializable {
 
     /** Serializable version identifier */
-    private static final long serialVersionUID = -942772950698439883L;
-    
+    private static final long serialVersionUID = 4605318041528645258L;
+
     /**
      * A default Number Transformer for Numbers and numeric Strings.
      */
@@ -44,13 +44,13 @@
     /**
      * The internal Map.
      */
-    private Map map = null;
+    private Map<Class<?>, NumberTransformer> map = null;
 
     /**
-     * 
+     * Build a map containing only the default transformer.
      */
     public TransformerMap() {
-        map = new HashMap();
+        map = new HashMap<Class<?>, NumberTransformer>();
         defaultTransformer = new DefaultTransformer();
     }
 
@@ -59,7 +59,7 @@
      * @param key Class to check
      * @return true|false
      */
-    public boolean containsClass(Class key) {
+    public boolean containsClass(Class<?> key) {
         return map.containsKey(key);
     }
 
@@ -78,7 +78,7 @@
      * @param key The Class of the object
      * @return the mapped NumberTransformer or null.
      */
-    public NumberTransformer getTransformer(Class key) {
+    public NumberTransformer getTransformer(Class<?> key) {
         return (NumberTransformer) map.get(key);
     }
 
@@ -90,7 +90,7 @@
      * @param transformer The NumberTransformer
      * @return the replaced transformer if one is present
      */
-    public Object putTransformer(Class key, NumberTransformer transformer) {
+    public NumberTransformer putTransformer(Class<?> key, NumberTransformer transformer) {
         return map.put(key, transformer);
     }
 
@@ -100,7 +100,7 @@
      * @return the removed transformer if one is present or
      * null if none was present.
      */
-    public Object removeTransformer(Class key) {
+    public NumberTransformer removeTransformer(Class<?> key) {
         return map.remove(key);
     }
 
@@ -115,7 +115,7 @@
      * Returns the Set of Classes used as keys in the map.
      * @return Set of Classes
      */
-    public Set classes() {
+    public Set<Class<?>> classes() {
         return map.keySet();
     }
 
@@ -124,7 +124,7 @@
      * in the map.
      * @return Set of NumberTransformers
      */
-    public Collection transformers() {
+    public Collection<NumberTransformer> transformers() {
         return map.values();
     }
 

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java Sun May 18 12:37:23 2008
@@ -19,15 +19,10 @@
 
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 
-import org.apache.commons.math.estimation.EstimatedParameter;
-import org.apache.commons.math.estimation.EstimationException;
-import org.apache.commons.math.estimation.EstimationProblem;
-import org.apache.commons.math.estimation.GaussNewtonEstimator;
-import org.apache.commons.math.estimation.WeightedMeasurement;
-
-import junit.framework.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
 
 /**
  * <p>Some of the unit tests are re-implementations of the MINPACK <a
@@ -570,7 +565,7 @@
   private static class LinearProblem extends SimpleEstimationProblem {
 
     public LinearProblem(LinearMeasurement[] measurements) {
-      HashSet set = new HashSet();
+      HashSet<EstimatedParameter> set = new HashSet<EstimatedParameter>();
       for (int i = 0; i < measurements.length; ++i) {
         addMeasurement(measurements[i]);
         EstimatedParameter[] parameters = measurements[i].getParameters();
@@ -578,8 +573,8 @@
           set.add(parameters[j]);
         }
       }
-      for (Iterator iterator = set.iterator(); iterator.hasNext();) {
-        addParameter((EstimatedParameter) iterator.next());
+      for (EstimatedParameter p : set) {
+        addParameter(p);
       }
     }
 
@@ -627,7 +622,7 @@
     public Circle(double cx, double cy) {
       this.cx = new EstimatedParameter("cx", cx);
       this.cy = new EstimatedParameter(new EstimatedParameter("cy", cy));
-      points  = new ArrayList();
+      points  = new ArrayList<PointModel>();
     }
 
     public void addPoint(double px, double py) {
@@ -652,24 +647,24 @@
 
     public double getPartialRadiusX() {
       double dRdX = 0;
-      for (Iterator iterator = points.iterator(); iterator.hasNext();) {
-        dRdX += ((PointModel) iterator.next()).getPartialDiX();
+      for (PointModel point : points) {
+        dRdX += point.getPartialDiX();
       }
       return dRdX / points.size();
     }
 
     public double getPartialRadiusY() {
       double dRdY = 0;
-      for (Iterator iterator = points.iterator(); iterator.hasNext();) {
-        dRdY += ((PointModel) iterator.next()).getPartialDiY();
+      for (PointModel point : points) {
+        dRdY += point.getPartialDiY();
       }
       return dRdY / points.size();
     }
 
    public double getRadius() {
       double r = 0;
-      for (Iterator iterator = points.iterator(); iterator.hasNext();) {
-        r += ((PointModel) iterator.next()).getCenterDistance();
+      for (PointModel point : points) {
+        r += point.getCenterDistance();
       }
       return r / points.size();
     }
@@ -725,7 +720,7 @@
 
     private EstimatedParameter cx;
     private EstimatedParameter cy;
-    private ArrayList points;
+    private ArrayList<PointModel> points;
 
   }
 

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java Sun May 18 12:37:23 2008
@@ -18,17 +18,11 @@
 package org.apache.commons.math.estimation;
 
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.commons.math.estimation.EstimatedParameter;
-import org.apache.commons.math.estimation.EstimationException;
-import org.apache.commons.math.estimation.EstimationProblem;
-import org.apache.commons.math.estimation.LevenbergMarquardtEstimator;
-import org.apache.commons.math.estimation.WeightedMeasurement;
+import java.util.HashSet;
 
-import junit.framework.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
 
 /**
  * <p>Some of the unit tests are re-implementations of the MINPACK <a
@@ -618,14 +612,13 @@
     }
 
     public EstimatedParameter[] getAllParameters() {
-      HashMap map = new HashMap();
+      HashSet<EstimatedParameter> set = new HashSet<EstimatedParameter>();
       for (int i = 0; i < measurements.length; ++i) {
         EstimatedParameter[] parameters = measurements[i].getParameters();
         for (int j = 0; j < parameters.length; ++j) {
-          map.put(parameters[j], null);
+          set.add(parameters[j]);
         }
       }
-      Set set = map.keySet();
       return (EstimatedParameter[]) set.toArray(new EstimatedParameter[set.size()]);
     }
   
@@ -674,7 +667,7 @@
     public Circle(double cx, double cy) {
       this.cx = new EstimatedParameter("cx", cx);
       this.cy = new EstimatedParameter("cy", cy);
-      points  = new ArrayList();
+      points  = new ArrayList<PointModel>();
     }
 
     public void addPoint(double px, double py) {
@@ -699,24 +692,24 @@
 
     public double getPartialRadiusX() {
       double dRdX = 0;
-      for (Iterator iterator = points.iterator(); iterator.hasNext();) {
-        dRdX += ((PointModel) iterator.next()).getPartialDiX();
+      for (PointModel point : points) {
+        dRdX += point.getPartialDiX();
       }
       return dRdX / points.size();
     }
 
     public double getPartialRadiusY() {
       double dRdY = 0;
-      for (Iterator iterator = points.iterator(); iterator.hasNext();) {
-        dRdY += ((PointModel) iterator.next()).getPartialDiY();
+      for (PointModel point : points) {
+        dRdY += point.getPartialDiY();
       }
       return dRdY / points.size();
     }
 
    public double getRadius() {
       double r = 0;
-      for (Iterator iterator = points.iterator(); iterator.hasNext();) {
-        r += ((PointModel) iterator.next()).getCenterDistance();
+      for (PointModel point : points) {
+        r += point.getCenterDistance();
       }
       return r / points.size();
     }
@@ -772,7 +765,7 @@
 
     private EstimatedParameter cx;
     private EstimatedParameter cy;
-    private ArrayList points;
+    private ArrayList<PointModel> points;
 
   }
 

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/EmpiricalDistributionTest.java Sun May 18 12:37:23 2008
@@ -16,16 +16,15 @@
  */
 package org.apache.commons.math.random;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
 
 import org.apache.commons.math.RetryTestCase;
 import org.apache.commons.math.TestUtils;
@@ -58,7 +57,7 @@
                 new BufferedReader(new InputStreamReader(
                         url.openStream()));
         String str = null;
-        ArrayList list = new ArrayList();
+        ArrayList<Double> list = new ArrayList<Double>();
         while ((str = in.readLine()) != null) {
             list.add(Double.valueOf(str));
         }
@@ -67,8 +66,8 @@
         
         dataArray = new double[list.size()];
         int i = 0;
-        for (Iterator iter = list.iterator(); iter.hasNext();) {
-            dataArray[i] = ((Double)iter.next()).doubleValue();
+        for (Double data : list) {
+            dataArray[i] = data.doubleValue();
             i++;
         }                 
     }

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/RandomDataTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/RandomDataTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/RandomDataTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/random/RandomDataTest.java Sun May 18 12:37:23 2008
@@ -486,14 +486,14 @@
        long[] observed = {0,0,0,0,0,0,0,0,0,0};
        double[] expected = {100,100,100,100,100,100,100,100,100,100};
        
-       HashSet cPop = new HashSet();  //{0,1,2,3,4}
+       HashSet<Object> cPop = new HashSet<Object>();  //{0,1,2,3,4}
        for (int i = 0; i < 5; i++) {
            cPop.add(Integer.toString(i));
        }
        
        Object[] sets = new Object[10]; // 2-sets from 5
        for (int i = 0; i < 10; i ++) {
-           HashSet hs = new HashSet();
+           HashSet<Object> hs = new HashSet<Object>();
            hs.add(c[i][0]);
            hs.add(c[i][1]);
            sets[i] = hs;
@@ -511,7 +511,7 @@
             testStatistic.chiSquare(expected,observed) < 27.88);  
        
        // Make sure sample of size = size of collection returns same collection
-       HashSet hs = new HashSet();
+       HashSet<Object> hs = new HashSet<Object>();
        hs.add("one");
        Object[] one = randomData.nextSample(hs,1);
        String oneString = (String) one[0];
@@ -529,18 +529,19 @@
        
        // Make sure we fail for empty collection
        try {
-           hs = new HashSet();
+           hs = new HashSet<Object>();
            one = randomData.nextSample(hs,0);
            fail("n = k = 0, expecting IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            ;
        }
     }
-    
+
+    @SuppressWarnings("unchecked")
     private int findSample(Object[] u, Object[] samp) {
         for (int i = 0; i < u.length; i++) {
-            HashSet set = (HashSet) u[i];
-            HashSet sampSet = new HashSet();
+            HashSet<Object> set = (HashSet<Object>) u[i];
+            HashSet<Object> sampSet = new HashSet<Object>();
             for (int j = 0; j < samp.length; j++) {
                 sampSet.add(samp[j]);
             }

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/data/CertifiedDataAbstractTest.java Sun May 18 12:37:23 2008
@@ -24,15 +24,14 @@
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
+import junit.framework.TestCase;
+
 import org.apache.commons.math.TestUtils;
 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
 import org.apache.commons.math.stat.descriptive.SummaryStatistics;
 
-import junit.framework.TestCase;
-
 /**
  * @version $Revision$ $Date$
  */
@@ -42,12 +41,12 @@
     
     private SummaryStatistics summaries;
     
-    private Map certifiedValues;
+    private Map<String, Double> certifiedValues;
     
     protected void setUp() throws Exception {
         descriptives = new DescriptiveStatistics();
         summaries = new SummaryStatistics();
-        certifiedValues = new HashMap();
+        certifiedValues = new HashMap<String, Double>();
         
         loadData();
     }
@@ -110,10 +109,7 @@
     }
     
     public void testCertifiedValues() {
-        Iterator iter = certifiedValues.keySet().iterator();
-
-        while (iter.hasNext()) {
-            String name = iter.next().toString();
+        for (String name : certifiedValues.keySet()) {
             Double expectedValue = (Double)certifiedValues.get(name);
 
             Double summariesValue = getProperty(summaries, name);

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImpl.java Sun May 18 12:37:23 2008
@@ -38,7 +38,7 @@
      * Holds a reference to a list - GENERICs are going to make
      * our lives easier here as we could only accept List<Number>
      */
-    protected List list;
+    protected List<Object> list;
 
     /** Number Transformer maps Objects to Number for us. */
     protected NumberTransformer transformer;
@@ -47,14 +47,14 @@
      * No argument Constructor
      */
     public ListUnivariateImpl(){
-        this(new ArrayList());
+        this(new ArrayList<Object>());
     }
     
     /**
      * Construct a ListUnivariate with a specific List.
      * @param list The list that will back this DescriptiveStatistics
      */
-    public ListUnivariateImpl(List list) {
+    public ListUnivariateImpl(List<Object> list) {
         this(list, new DefaultTransformer());
     }
     
@@ -63,7 +63,7 @@
      * @param list The list that will back this DescriptiveStatistics
      * @param transformer the number transformer used to convert the list items.
      */
-    public ListUnivariateImpl(List list, NumberTransformer transformer) {
+    public ListUnivariateImpl(List<Object> list, NumberTransformer transformer) {
         super();
         this.list = list;
         this.transformer = transformer;

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/ListUnivariateImplTest.java Sun May 18 12:37:23 2008
@@ -62,7 +62,7 @@
     
     /** test stats */
     public void testStats() {
-        List externalList = new ArrayList();
+        List<Object> externalList = new ArrayList<Object>();
         
         DescriptiveStatistics u = new ListUnivariateImpl( externalList ); 
 
@@ -84,7 +84,7 @@
     }     
     
     public void testN0andN1Conditions() throws Exception {
-        List list = new ArrayList();
+        List<Object> list = new ArrayList<Object>();
         
         DescriptiveStatistics u = new ListUnivariateImpl( list );
                 
@@ -115,7 +115,7 @@
     }
 
     public void testProductAndGeometricMean() throws Exception {
-        ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList());
+        ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<Object>());
         u.setWindowSize(10);
                 
         u.addValue( 1.0 );

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java Sun May 18 12:37:23 2008
@@ -69,7 +69,7 @@
 
     /** test stats */
     public void testStats() {
-        List externalList = new ArrayList();
+        List<Object> externalList = new ArrayList<Object>();
 
         DescriptiveStatistics u = new ListUnivariateImpl(externalList,transformers);
 
@@ -91,7 +91,7 @@
     }
 
     public void testN0andN1Conditions() throws Exception {
-        DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList(),transformers);
+        DescriptiveStatistics u = new ListUnivariateImpl(new ArrayList<Object>(),transformers);
 
         assertTrue(
             "Mean of n = 0 set should be NaN",
@@ -120,7 +120,7 @@
 
     public void testSkewAndKurtosis() {
         ListUnivariateImpl u =
-            new ListUnivariateImpl(new ArrayList(), transformers);
+            new ListUnivariateImpl(new ArrayList<Object>(), transformers);
 
         u.addObject("12.5");
         u.addObject(new Integer(12));
@@ -153,7 +153,7 @@
     }
 
     public void testProductAndGeometricMean() throws Exception {
-        ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList(),transformers);
+        ListUnivariateImpl u = new ListUnivariateImpl(new ArrayList<Object>(),transformers);
         u.setWindowSize(10);
 
         u.addValue(1.0);

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/OneWayAnovaTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/OneWayAnovaTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/OneWayAnovaTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/OneWayAnovaTest.java Sun May 18 12:37:23 2008
@@ -33,7 +33,6 @@
 
     protected OneWayAnova testStatistic = new OneWayAnovaImpl();
     
-    private char[] wrongArray = { 'a', 'b', 'c' };
     private double[] emptyArray = {};
 
     private double[] classA =
@@ -58,7 +57,7 @@
 
     public void testAnovaFValue() throws Exception {
         // Target comparison values computed using R version 2.6.0 (Linux version)
-        List threeClasses = new ArrayList();
+        List<double[]> threeClasses = new ArrayList<double[]>();
         threeClasses.add(classA);
         threeClasses.add(classB);
         threeClasses.add(classC);
@@ -66,25 +65,14 @@
         assertEquals("ANOVA F-value",  24.67361709460624,
                  testStatistic.anovaFValue(threeClasses), 1E-12);
 
-        List twoClasses = new ArrayList();
+        List<double[]> twoClasses = new ArrayList<double[]>();
         twoClasses.add(classA);
         twoClasses.add(classB);
         
         assertEquals("ANOVA F-value",  0.0150579150579,
                  testStatistic.anovaFValue(twoClasses), 1E-12);
 
-        // now try some input hashes which should fail
-        List wrongContents = new ArrayList();
-        wrongContents.add(classC);
-        wrongContents.add(wrongArray);
-        try {
-            testStatistic.anovaFValue(wrongContents);
-            fail("non double[] hash value for key classX, IllegalArgumentException expected");
-        } catch (IllegalArgumentException ex) {
-            // expected
-        }  
-
-        List emptyContents = new ArrayList();
+        List<double[]> emptyContents = new ArrayList<double[]>();
         emptyContents.add(emptyArray);
         emptyContents.add(classC);
         try {
@@ -94,7 +82,7 @@
             // expected
         }  
 
-        List tooFew = new ArrayList();
+        List<double[]> tooFew = new ArrayList<double[]>();
         tooFew.add(classA);
         try {
             testStatistic.anovaFValue(tooFew);
@@ -107,7 +95,7 @@
 
     public void testAnovaPValue() throws Exception {
         // Target comparison values computed using R version 2.6.0 (Linux version)
-        List threeClasses = new ArrayList();
+        List<double[]> threeClasses = new ArrayList<double[]>();
         threeClasses.add(classA);
         threeClasses.add(classB);
         threeClasses.add(classC);
@@ -115,7 +103,7 @@
         assertEquals("ANOVA P-value", 6.959446E-06,
                  testStatistic.anovaPValue(threeClasses), 1E-12);
 
-        List twoClasses = new ArrayList();
+        List<double[]> twoClasses = new ArrayList<double[]>();
         twoClasses.add(classA);
         twoClasses.add(classB);
         
@@ -126,14 +114,14 @@
 
     public void testAnovaTest() throws Exception {
         // Target comparison values computed using R version 2.3.1 (Linux version)
-        List threeClasses = new ArrayList();
+        List<double[]> threeClasses = new ArrayList<double[]>();
         threeClasses.add(classA);
         threeClasses.add(classB);
         threeClasses.add(classC);
 
         assertTrue("ANOVA Test P<0.01", testStatistic.anovaTest(threeClasses, 0.01));
 
-        List twoClasses = new ArrayList();
+        List<double[]> twoClasses = new ArrayList<double[]>();
         twoClasses.add(classA);
         twoClasses.add(classB);
         

Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java?rev=657612&r1=657611&r2=657612&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/stat/inference/TestUtilsTest.java Sun May 18 12:37:23 2008
@@ -451,7 +451,7 @@
     private double[] classC =
       {110.0, 115.0, 111.0, 117.0, 128.0};
     
-    private List classes = new ArrayList();
+    private List<double[]> classes = new ArrayList<double[]>();
     private OneWayAnova oneWayAnova = new OneWayAnovaImpl();
     
     public void testOneWayAnovaUtils() throws Exception {



Mime
View raw message