From c925bd6304fc69b3aa2d9625e89fbd78ae4a2353 Mon Sep 17 00:00:00 2001 From: mdb Date: Thu, 10 Apr 2003 20:50:47 +0000 Subject: [PATCH] Added method for tersely summarizing the histogram. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1095 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/Histogram.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/Histogram.java b/projects/samskivert/src/java/com/samskivert/util/Histogram.java index ef113502..ff24e38d 100644 --- a/projects/samskivert/src/java/com/samskivert/util/Histogram.java +++ b/projects/samskivert/src/java/com/samskivert/util/Histogram.java @@ -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 // Copyright (C) 2001 Michael Bayne @@ -84,6 +84,24 @@ public class Histogram 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. */