StringBuffer => StringBuilder for local variables

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1042422 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2010-12-05 19:25:21 +00:00
parent 4d4aa195fe
commit 52e8a34e72
11 changed files with 18 additions and 18 deletions

View File

@ -281,7 +281,7 @@ public class PolynomialFunction implements DifferentiableUnivariateRealFunction,
@Override
public String toString() {
StringBuffer s = new StringBuffer();
StringBuilder s = new StringBuilder();
if (coefficients[0] == 0.0) {
if (coefficients.length == 1) {
return "0";

View File

@ -359,14 +359,14 @@ public class DfpMath {
// X is now in the range of 2/3 < x < 4/3
Dfp[] spz = logInternal(spx);
spx[0] = a.newInstance(new StringBuffer().append(p2+4*lr).toString());
spx[0] = a.newInstance(new StringBuilder().append(p2+4*lr).toString());
spx[1] = a.getZero();
spy = splitMult(a.getField().getLn2Split(), spx);
spz[0] = spz[0].add(spy[0]);
spz[1] = spz[1].add(spy[1]);
spx[0] = a.newInstance(new StringBuffer().append(4*lr).toString());
spx[0] = a.newInstance(new StringBuilder().append(4*lr).toString());
spx[1] = a.getZero();
spy = splitMult(a.getField().getLn5Split(), spx);

View File

@ -159,7 +159,7 @@ public class RandomDataImpl implements RandomData, Serializable {
RandomGenerator ran = getRan();
// Initialize output buffer
StringBuffer outBuffer = new StringBuffer();
StringBuilder outBuffer = new StringBuilder();
// Get int(len/2)+1 random bytes
byte[] randomBytes = new byte[(len / 2) + 1];
@ -265,7 +265,7 @@ public class RandomDataImpl implements RandomData, Serializable {
// Compute number of iterations required (40 bytes each)
int numIter = (len / 40) + 1;
StringBuffer outBuffer = new StringBuffer();
StringBuilder outBuffer = new StringBuilder();
for (int iter = 1; iter < numIter + 1; iter++) {
byte[] randomBytes = new byte[40];
secRan.nextBytes(randomBytes);

View File

@ -80,7 +80,7 @@ public class Frequency implements Serializable {
@Override
public String toString() {
NumberFormat nf = NumberFormat.getPercentInstance();
StringBuffer outBuffer = new StringBuffer();
StringBuilder outBuffer = new StringBuilder();
outBuffer.append("Value \t Freq. \t Pct. \t Cum Pct. \n");
Iterator<Comparable<?>> iter = freqTable.keySet().iterator();
while (iter.hasNext()) {

View File

@ -105,7 +105,7 @@ public class EuclideanIntegerPoint implements Clusterable<EuclideanIntegerPoint>
*/
@Override
public String toString() {
final StringBuffer buff = new StringBuffer("(");
final StringBuilder buff = new StringBuilder("(");
final int[] coordinates = getPoint();
for (int i = 0; i < coordinates.length; i++) {
buff.append(coordinates[i]);

View File

@ -409,7 +409,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable {
*/
@Override
public String toString() {
StringBuffer outBuffer = new StringBuffer();
StringBuilder outBuffer = new StringBuilder();
String endl = "\n";
outBuffer.append("DescriptiveStatistics:").append(endl);
outBuffer.append("n: ").append(getN()).append(endl);

View File

@ -307,7 +307,7 @@ public class MultivariateSummaryStatistics
public String toString() {
final String separator = ", ";
final String suffix = System.getProperty("line.separator");
StringBuffer outBuffer = new StringBuffer();
StringBuilder outBuffer = new StringBuilder();
outBuffer.append("MultivariateSummaryStatistics:" + suffix);
outBuffer.append("n: " + getN() + suffix);
append(outBuffer, getMin(), "min: ", separator, suffix);
@ -329,7 +329,7 @@ public class MultivariateSummaryStatistics
* @param separator elements separator
* @param suffix text suffix
*/
private void append(StringBuffer buffer, double[] data,
private void append(StringBuilder buffer, double[] data,
String prefix, String separator, String suffix) {
buffer.append(prefix);
for (int i = 0; i < data.length; ++i) {

View File

@ -309,7 +309,7 @@ public class SummaryStatistics implements StatisticalSummary, Serializable {
*/
@Override
public String toString() {
StringBuffer outBuffer = new StringBuffer();
StringBuilder outBuffer = new StringBuilder();
String endl = "\n";
outBuffer.append("SummaryStatistics:").append(endl);
outBuffer.append("n: ").append(getN()).append(endl);

View File

@ -109,7 +109,7 @@ public abstract class CompositeFormat extends Format {
final ParsePosition pos) {
Number ret = null;
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append('(');
sb.append(value);
sb.append(')');

View File

@ -264,7 +264,7 @@ public class TestUtils {
if (expected.getColumnDimension() != observed.getColumnDimension() ||
expected.getRowDimension() != observed.getRowDimension()) {
StringBuffer messageBuffer = new StringBuffer(msg);
StringBuilder messageBuffer = new StringBuilder(msg);
messageBuffer.append("\nObserved has incorrect dimensions.");
messageBuffer.append("\nobserved is " + observed.getRowDimension() +
" x " + observed.getColumnDimension());
@ -275,7 +275,7 @@ public class TestUtils {
RealMatrix delta = expected.subtract(observed);
if (delta.getNorm() >= tolerance) {
StringBuffer messageBuffer = new StringBuffer(msg);
StringBuilder messageBuffer = new StringBuilder(msg);
messageBuffer.append("\nExpected: " + expected);
messageBuffer.append("\nObserved: " + observed);
messageBuffer.append("\nexpected - observed: " + delta);
@ -291,7 +291,7 @@ public class TestUtils {
if (expected.getColumnDimension() != observed.getColumnDimension() ||
expected.getRowDimension() != observed.getRowDimension()) {
StringBuffer messageBuffer = new StringBuffer();
StringBuilder messageBuffer = new StringBuilder();
messageBuffer.append("Observed has incorrect dimensions.");
messageBuffer.append("\nobserved is " + observed.getRowDimension() +
" x " + observed.getColumnDimension());
@ -312,7 +312,7 @@ public class TestUtils {
/** verifies that two arrays are close (sup norm) */
public static void assertEquals(String msg, double[] expected, double[] observed,
double tolerance) {
StringBuffer out = new StringBuffer(msg);
StringBuilder out = new StringBuilder(msg);
if (expected.length != observed.length) {
out.append("\n Arrays not same length. \n");
out.append("expected has length ");
@ -382,7 +382,7 @@ public class TestUtils {
// Fail if we can reject null hypothesis that distributions are the same
Assert.assertFalse(chiSquareTest.chiSquareTest(expected, observed, alpha));
} catch (AssertionFailedError ex) {
StringBuffer msgBuffer = new StringBuffer();
StringBuilder msgBuffer = new StringBuilder();
DecimalFormat df = new DecimalFormat("#.##");
msgBuffer.append("Chisquare test failed");
msgBuffer.append(" p-value = ");

View File

@ -355,7 +355,7 @@ public class RandomDataTest extends RetryTestCase {
// Fail if we can reject null hypothesis that distributions are the same
assertFalse(chiSquareTest.chiSquareTest(expected, observed, alpha));
} catch (AssertionFailedError ex) {
StringBuffer msgBuffer = new StringBuffer();
StringBuilder msgBuffer = new StringBuilder();
DecimalFormat df = new DecimalFormat("#.##");
msgBuffer.append("Chisquare test failed for mean = ");
msgBuffer.append(mean);