From 066259d0359c18210f1b6293771a62f98deca76d Mon Sep 17 00:00:00 2001 From: hollings Date: Wed, 20 Apr 1994 15:19:22 +0000 Subject: [PATCH] Added method to get histogram buckets. --- common/h/hist.h | 1 + common/src/hist.C | 22 +++++++++++++++++++++- pdutil/h/hist.h | 1 + pdutil/src/hist.C | 22 +++++++++++++++++++++- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/common/h/hist.h b/common/h/hist.h index c4f78aa..c5d1d82 100644 --- a/common/h/hist.h +++ b/common/h/hist.h @@ -43,6 +43,7 @@ class Histogram { Histogram(Bin *buckets, metricStyle, dataCallBack, foldCallBack, void*); sampleValue getValue(); sampleValue getValue(timeStamp start, timeStamp end); + int getBuckets(sampleValue *buckets, int numberOfBuckets, int first); void addInterval(timeStamp start, timeStamp end, sampleValue value, Boolean smooth); void addPoint(timeStamp start, sampleValue value) { diff --git a/common/src/hist.C b/common/src/hist.C index a77e8fc..0769602 100644 --- a/common/src/hist.C +++ b/common/src/hist.C @@ -16,7 +16,10 @@ * hist.C - routines to manage hisograms. * * $Log: hist.C,v $ - * Revision 1.6 1994/04/12 22:11:22 hollings + * Revision 1.7 1994/04/20 15:19:30 hollings + * Added method to get histogram buckets. + * + * Revision 1.6 1994/04/12 22:11:22 hollings * removed special case of bucket a zero value since it caused upcalls not to * happen. * @@ -380,3 +383,20 @@ sampleValue Histogram::getValue() { return(getValue(0.0, numBins * bucketSize)); } + +int Histogram::getBuckets(sampleValue *buckets, int numberOfBuckets, int first) +{ + int i; + int last; + + last = first + numberOfBuckets; + if (lastBin < last) last = lastBin; + + // make sure its in bin form. + convertToBins(); + + for (i=first; i < last; i++) { + buckets[i-first] = dataPtr.buckets[i]; + } + return(last-first); +} diff --git a/pdutil/h/hist.h b/pdutil/h/hist.h index c4f78aa..c5d1d82 100644 --- a/pdutil/h/hist.h +++ b/pdutil/h/hist.h @@ -43,6 +43,7 @@ class Histogram { Histogram(Bin *buckets, metricStyle, dataCallBack, foldCallBack, void*); sampleValue getValue(); sampleValue getValue(timeStamp start, timeStamp end); + int getBuckets(sampleValue *buckets, int numberOfBuckets, int first); void addInterval(timeStamp start, timeStamp end, sampleValue value, Boolean smooth); void addPoint(timeStamp start, sampleValue value) { diff --git a/pdutil/src/hist.C b/pdutil/src/hist.C index a77e8fc..0769602 100644 --- a/pdutil/src/hist.C +++ b/pdutil/src/hist.C @@ -16,7 +16,10 @@ * hist.C - routines to manage hisograms. * * $Log: hist.C,v $ - * Revision 1.6 1994/04/12 22:11:22 hollings + * Revision 1.7 1994/04/20 15:19:30 hollings + * Added method to get histogram buckets. + * + * Revision 1.6 1994/04/12 22:11:22 hollings * removed special case of bucket a zero value since it caused upcalls not to * happen. * @@ -380,3 +383,20 @@ sampleValue Histogram::getValue() { return(getValue(0.0, numBins * bucketSize)); } + +int Histogram::getBuckets(sampleValue *buckets, int numberOfBuckets, int first) +{ + int i; + int last; + + last = first + numberOfBuckets; + if (lastBin < last) last = lastBin; + + // make sure its in bin form. + convertToBins(); + + for (i=first; i < last; i++) { + buckets[i-first] = dataPtr.buckets[i]; + } + return(last-first); +} -- 1.8.3.1