Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6C8AFD89D for ; Sat, 17 Nov 2012 01:09:12 +0000 (UTC) Received: (qmail 96382 invoked by uid 500); 17 Nov 2012 01:09:12 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 96316 invoked by uid 500); 17 Nov 2012 01:09:12 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 96300 invoked by uid 99); 17 Nov 2012 01:09:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Nov 2012 01:09:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Nov 2012 01:09:10 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 25BD02388A3F for ; Sat, 17 Nov 2012 01:08:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1410657 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java Date: Sat, 17 Nov 2012 01:08:49 -0000 To: commits@commons.apache.org From: erans@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121117010850.25BD02388A3F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: erans Date: Sat Nov 17 01:08:49 2012 New Revision: 1410657 URL: http://svn.apache.org/viewvc?rev=1410657&view=rev Log: MATH-894 Name change ("contractionCriteria" -> "contractionCriterion"). Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java?rev=1410657&r1=1410656&r2=1410657&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/ResizableDoubleArray.java Sat Nov 17 01:08:49 2012 @@ -97,7 +97,7 @@ public class ResizableDoubleArray implem /** Default value for array size modifier. */ private static final double DEFAULT_EXPANSION_FACTOR = 2.0; /** - * Default value for the difference between {@link #contractionCriteria} + * Default value for the difference between {@link #contractionCriterion} * and {@link #expansionFactor}. */ private static final double DEFAULT_CONTRACTION_DELTA = 0.5; @@ -107,7 +107,7 @@ public class ResizableDoubleArray implem * contracted to fit the number of elements contained in the element * array + 1. */ - private double contractionCriteria = 2.5; + private double contractionCriterion = 2.5; /** * The expansion factor of the array. When the array needs to be expanded, @@ -159,7 +159,7 @@ public class ResizableDoubleArray implem *
  • {@code initialCapacity = 16}
  • *
  • {@code expansionMode = MULTIPLICATIVE}
  • *
  • {@code expansionFactor = 2.0}
  • - *
  • {@code contractionFactor = 2.5}
  • + *
  • {@code contractionCriterion = 2.5}
  • * */ public ResizableDoubleArray() { @@ -172,7 +172,7 @@ public class ResizableDoubleArray implem *
      *
    • {@code expansionMode = MULTIPLICATIVE}
    • *
    • {@code expansionFactor = 2.0}
    • - *
    • {@code contractionFactor = 2.5}
    • + *
    • {@code contractionCriterion = 2.5}
    • *
    * @param initialCapacity Initial size of the internal storage array. * @throws MathIllegalArgumentException if {@code initialCapacity <= 0}. @@ -194,7 +194,7 @@ public class ResizableDoubleArray implem *
  • {@code initialCapacity = 16}
  • *
  • {@code expansionMode = MULTIPLICATIVE}
  • *
  • {@code expansionFactor = 2.0}
  • - *
  • {@code contractionFactor = 2.5}
  • + *
  • {@code contractionCriterion = 2.5}
  • * * * @param initialArray initial array @@ -214,7 +214,7 @@ public class ResizableDoubleArray implem * The remaining properties take default values: *
      *
    • {@code expansionMode = MULTIPLICATIVE}
    • - *
    • {@code contractionFactor = 0.5 + expansionFactor}
    • + *
    • {@code contractionCriterion = 0.5 + expansionFactor}
    • *
    *
    * Throws IllegalArgumentException if the following conditions are @@ -245,7 +245,7 @@ public class ResizableDoubleArray implem * The remaining properties take default values: *
      *
    • {@code expansionMode = MULTIPLICATIVE}
    • - *
    • {@code contractionFactor = 0.5 + expansionFactor}
    • + *
    • {@code contractionCriterion = 0.5 + expansionFactor}
    • *
    *
    * Throws IllegalArgumentException if the following conditions are @@ -270,7 +270,7 @@ public class ResizableDoubleArray implem /** * Creates an instance with the specified initialCapacity, - * expansionFactor, and contractionCriteria. + * expansionFactor, and contractionCriterion. * The expansion mode will default to {@code MULTIPLICATIVE}. *
    * Throws IllegalArgumentException if the following conditions are @@ -278,7 +278,7 @@ public class ResizableDoubleArray implem *
      *
    • {@code initialCapacity > 0}
    • *
    • {@code expansionFactor > 1}
    • - *
    • {@code contractionFactor >= expansionFactor}
    • + *
    • {@code contractionCriterion >= expansionFactor}
    • *
    * * @param initialCapacity Initial size of the internal storage array.. @@ -300,8 +300,8 @@ public class ResizableDoubleArray implem } /** - * Creates an instance with the specified initialCapacity, - * expansionFactor, and contractionCriteria. + * Creates an instance with the specified initial capacity, + * expansion factor, and contraction criteria. * The expansion mode will default to {@code MULTIPLICATIVE}. *
    * Throws IllegalArgumentException if the following conditions are @@ -309,22 +309,22 @@ public class ResizableDoubleArray implem *
      *
    • {@code initialCapacity > 0}
    • *
    • {@code expansionFactor > 1}
    • - *
    • {@code contractionFactor >= expansionFactor}
    • + *
    • {@code contractionCriterion >= expansionFactor}
    • *
    * * @param initialCapacity Initial size of the internal storage array.. * @param expansionFactor The array will be expanded based on this * parameter. - * @param contractionCriteria Contraction criteria. - * @throws MathIllegalArgumentException if parameters are not valid. + * @param contractionCriterion Contraction criterion. + * @throws MathIllegalArgumentException if the parameters are not valid. */ public ResizableDoubleArray(int initialCapacity, double expansionFactor, - double contractionCriteria) + double contractionCriterion) throws MathIllegalArgumentException { this(initialCapacity, expansionFactor, - contractionCriteria, + contractionCriterion, ExpansionMode.MULTIPLICATIVE, null); } @@ -375,20 +375,20 @@ public class ResizableDoubleArray implem *
      *
    • {@code initialCapacity > 0}
    • *
    • {@code expansionFactor > 1}
    • - *
    • {@code contractionFactor >= expansionFactor}
    • + *
    • {@code contractionCriterion >= expansionFactor}
    • *
    * * @param initialCapacity Initial size of the internal storage array. * @param expansionFactor The array will be expanded based on this * parameter. - * @param contractionCriteria Contraction criteria. + * @param contractionCriterion Contraction criteria. * @param expansionMode Expansion mode. * @param data Initial contents of the array. * @throws MathIllegalArgumentException if the parameters are not valid. */ public ResizableDoubleArray(int initialCapacity, double expansionFactor, - double contractionCriteria, + double contractionCriterion, ExpansionMode expansionMode, double ... data) throws MathIllegalArgumentException { @@ -396,10 +396,10 @@ public class ResizableDoubleArray implem throw new NotStrictlyPositiveException(LocalizedFormats.INITIAL_CAPACITY_NOT_POSITIVE, initialCapacity); } - checkContractExpand(contractionCriteria, expansionFactor); + checkContractExpand(contractionCriterion, expansionFactor); this.expansionFactor = expansionFactor; - this.contractionCriteria = contractionCriteria; + this.contractionCriterion = contractionCriterion; this.expansionMode = expansionMode; internalArray = new double[initialCapacity]; numElements = 0; @@ -481,7 +481,7 @@ public class ResizableDoubleArray implem // Add the new value internalArray[startIndex + (numElements - 1)] = value; - // Check the contraction criteria + // Check the contraction criterion. if (shouldContract()) { contract(); } @@ -514,7 +514,7 @@ public class ResizableDoubleArray implem } /** - * Checks the expansion factor and the contraction criteria and throws an + * Checks the expansion factor and the contraction criterion and throws an * IllegalArgumentException if the contractionCriteria is less than the * expansionCriteria * @@ -532,18 +532,19 @@ public class ResizableDoubleArray implem } /** - * Checks the expansion factor and the contraction criteria and throws an - * IllegalArgumentException if the contractionCriteria is less than the - * expansionCriteria - * - * @param expansion factor to be checked - * @param contraction criteria to be checked - * @throws MathIllegalArgumentException if the contractionCriteria is less than - * the expansionCriteria. + * Checks the expansion factor and the contraction criterion and raises + * an exception if the contraction criterion is smaller than the + * expansion criterion. + * + * @param contraction Criterion to be checked. + * @param expansion Factor to be checked. + * @throws NumberIsTooSmallException if {@code contraction < expansion}. + * @throws NumberIsTooSmallException if {@code contraction <= 1}. + * @throws NumberIsTooSmallException if {@code expansion <= 1 }. */ protected void checkContractExpand(double contraction, double expansion) - throws MathIllegalArgumentException { + throws NumberIsTooSmallException { if (contraction < expansion) { final NumberIsTooSmallException e = new NumberIsTooSmallException(contraction, 1, true); e.getContext().addMessage(LocalizedFormats.CONTRACTION_CRITERIA_SMALLER_THAN_EXPANSION_FACTOR, @@ -736,7 +737,7 @@ public class ResizableDoubleArray implem * @return the contraction criterion used to reclaim memory. */ public double getContractionCriterion() { - return contractionCriteria; + return contractionCriterion; } /** @@ -910,7 +911,7 @@ public class ResizableDoubleArray implem throws MathIllegalArgumentException { checkContractExpand(contractionCriteria, getExpansionFactor()); synchronized(this) { - this.contractionCriteria = contractionCriteria; + this.contractionCriterion = contractionCriteria; } } @@ -960,7 +961,7 @@ public class ResizableDoubleArray implem * than contractionFactor */ public void setExpansionFactor(float expansionFactor) throws MathIllegalArgumentException { - checkContractExpand(getContractionCriteria(), expansionFactor); + checkContractExpand(getContractionCriterion(), expansionFactor); // The check above verifies that the expansion factor is > 1.0; synchronized(this) { this.expansionFactor = expansionFactor; @@ -1052,9 +1053,9 @@ public class ResizableDoubleArray implem */ private synchronized boolean shouldContract() { if (expansionMode == ExpansionMode.MULTIPLICATIVE) { - return (internalArray.length / ((float) numElements)) > contractionCriteria; + return (internalArray.length / ((float) numElements)) > contractionCriterion; } else { - return (internalArray.length - numElements) > contractionCriteria; + return (internalArray.length - numElements) > contractionCriterion; } } @@ -1097,7 +1098,7 @@ public class ResizableDoubleArray implem MathUtils.checkNotNull(dest); synchronized(source) { synchronized(dest) { - dest.contractionCriteria = source.contractionCriteria; + dest.contractionCriterion = source.contractionCriterion; dest.expansionFactor = source.expansionFactor; dest.expansionMode = source.expansionMode; dest.internalArray = new double[source.internalArray.length]; @@ -1144,7 +1145,7 @@ public class ResizableDoubleArray implem synchronized(object) { boolean result = true; final ResizableDoubleArray other = (ResizableDoubleArray) object; - result = result && (other.contractionCriteria == contractionCriteria); + result = result && (other.contractionCriterion == contractionCriterion); result = result && (other.expansionFactor == expansionFactor); result = result && (other.expansionMode == expansionMode); result = result && (other.numElements == numElements); @@ -1168,7 +1169,7 @@ public class ResizableDoubleArray implem public synchronized int hashCode() { final int[] hashData = new int[6]; hashData[0] = new Float(expansionFactor).hashCode(); - hashData[1] = new Float(contractionCriteria).hashCode(); + hashData[1] = new Float(contractionCriterion).hashCode(); hashData[2] = expansionMode.hashCode(); hashData[3] = Arrays.hashCode(internalArray); hashData[4] = numElements;