[CJ-dev] commonjava-projects/commonjava-diff/src/java/org/commonjava/diff DescriptiveStats.java,NONE
Brought to you by:
johnqueso
From: John C. <joh...@co...> - 2004-07-09 21:43:22
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-diff/src/java/org/commonjava/diff In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17552/src/java/org/commonjava/diff Modified Files: ByteMapping.java DiffEngine.java Added Files: DescriptiveStats.java Removed Files: Main.java Log Message: o Separated Main into subproject called 'cli' to remove requirement for commonjava-console in main diff engine project, o Removed dependency on FileSizeConstants, and hence commonjava-util o Copied DescriptiveStats from commonjava-math to . (commonjava-diff) to remove dependency on that lib. o Re-tested engine, and all's well. Index: DiffEngine.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-diff/src/java/org/commonjava/diff/DiffEngine.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DiffEngine.java 17 Jan 2004 04:12:47 -0000 1.1 +++ DiffEngine.java 9 Jul 2004 21:43:11 -0000 1.2 @@ -26,7 +26,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.commonjava.util.FileSizeConstants; /** Engine that is used to compute a set of operations that will turn * one binary data set into another one, effectively computing the difference @@ -40,8 +39,6 @@ private static final Log LOG = LogFactory.getLog(DiffEngine.class); - private static final DiffEngine INSTANCE = new DiffEngine(); - private static final byte[] ZERO_LEN_BYTE_ARRAY = new byte[0]; private static final DiffEngine.OffsetFirstOpComparator OFFSET_FIRST = @@ -50,19 +47,10 @@ private static final DiffEngine.TypeFirstOpComparator TYPE_FIRST = new DiffEngine.TypeFirstOpComparator(); - private static final int DEFAULT_LINE_MAX = FileSizeConstants.ONE_KILOBYTE; - private static final int DEFAULT_LINE_MIN = 100; - - /** Denies creation of a new instance of Diff */ - private DiffEngine() { - } + private static final int DEFAULT_LINE_MAX = 1024; // 1K + private static final int DEFAULT_LINE_MIN = 10; - /** Returns the singleton instance of this engine. - * - * @return the singleton - */ - public static DiffEngine getInstance(){ - return INSTANCE; + public DiffEngine() { } /** Read the contents of the old file, apply the operations to --- Main.java DELETED --- Index: ByteMapping.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-diff/src/java/org/commonjava/diff/ByteMapping.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ByteMapping.java 17 Jan 2004 04:12:47 -0000 1.1 +++ ByteMapping.java 9 Jul 2004 21:43:11 -0000 1.2 @@ -19,7 +19,7 @@ import java.util.Iterator; import java.util.List; -import org.commonjava.math.DescriptiveStats; +import org.commonjava.diff.DescriptiveStats; /** Stores a count of a byte in a file, for the purpose * of calculating line breaks for binary files. --- NEW FILE: DescriptiveStats.java --- /* Copyright (c) 2002 John Casey. All rights reserved. SEE licenses/cj-license.txt FOR MORE INFORMATION. */ /* * DescriptiveStats.java * * Created on November 2, 2002, 3:27 PM */ package org.commonjava.diff; /** Utility class providing access to some basic descriptive statistics operations. * * @author John Casey */ public final class DescriptiveStats { /** Creates a new instance of DescriptiveStats */ private DescriptiveStats() { } /** Calculates the standard deviation for an array of data points. * @param points The data points. * @return the standard deviation. */ public static double stdDev(double[] points){ double stdDev = Math.sqrt(variance(points)); return stdDev; } /** Calculates the variance for an array of data points. * @param points The data points. * @return the variance. */ public static double variance(double[] points){ double sigma = 0; double sigmaSq = 0; for(int i=0, len=points.length; i<len; i++){ sigma += points[i]; sigmaSq += Math.pow(points[i], 2); } double sigmaOp1 = Math.pow(sigma, 2)/points.length; double sSq = (sigmaSq + sigmaOp1) / (points.length -1); return sSq; } } |