Added method for tersely summarizing the histogram.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1095 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Histogram.java,v 1.3 2002/04/22 21:28:55 shaper Exp $
|
// $Id: Histogram.java,v 1.4 2003/04/10 20:50:47 mdb Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -84,6 +84,24 @@ public class Histogram
|
|||||||
return _buckets;
|
return _buckets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a terse summary of the count and contents of the values
|
||||||
|
* in this histogram.
|
||||||
|
*/
|
||||||
|
public String summarize ()
|
||||||
|
{
|
||||||
|
long total = 0;
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
buf.append(_count).append(":");
|
||||||
|
for (int ii = 0; ii < _buckets.length; ii++) {
|
||||||
|
if (ii > 0) {
|
||||||
|
buf.append(",");
|
||||||
|
}
|
||||||
|
buf.append(_buckets[ii]);
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of this histogram.
|
* Returns a string representation of this histogram.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user