/usr/include/sipxtapi/utl/UtlHistogram.h is in libsipxtapi-dev 3.3.0~test17-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | //
// Copyright (C) 2004-2006 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// $$
///////////////////////////////////////////////////////////////////////////////
#ifndef _UtlHistogram_h_
#define _UtlHistogram_h_
// SYSTEM INCLUDES
// APPLICATION INCLUDES
#include "utl/UtlString.h"
// DEFINES
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS
/**
* Record and dump counts in a series of bins.
*
* Recorded values are integers. The histogram has a specified number
* of bins, each counting the number of values over a range, each of
* which has the same specified width.
*
* The number of bins implemented is 2 more than the specified number,
* to allow one bin for values lower than the range and one for values
* higher than the range.
*
* The minimum of the range of bin 0 is Base, and each normal bin has
* a range of Size values.
*
* The first normal bin is numbered 0, so the bin for too-low values
* is numbered -1. Thus, the bins record:
*
* Bin -1 counts values less than "Base".
* Bin 0 counts values from "Base" to "Base + Size - 1".
* Bin 1 counts values from "Base + Size" to "Base + 2*Size - 1".
* Bin n counts values from "Base + n*Size" to "Base + (n+1)*Size - 1".
* Bin NoOfBins-1 counts values from "Base + (NoOfBins-1)*Size" to
* "Base + NoOfBins*Size -1".
* Bin NoOfBins counts values greater than or equal to "Base + NoOfBins*Size".
*
* The values of all the bins can be extracted in a string by setting
* outputFormat and outputWidth when the histogram is created.
* Calling show() formats each bin's value via
* sprintf(buffer, outputFomat, bin-value), concatenates them
* together, and returns the result as a UtlString.
* outputFormat must be a format string for formatting a single int,
* and it must always generate at most outputWidth characters.
*
* The outputFormat string must remain valid as long as the histogram
* object exists; the returned UtlString must be freed by the caller.
*/
class UtlHistogram
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:
/* ============================ CREATORS ================================== */
/**
* Constructor.
*/
UtlHistogram(unsigned int bins, int base, unsigned int size,
const char* outputFormat = "", unsigned int outputWidth = 0);
/**
* Destructor
*/
~UtlHistogram();
/* ============================ MANIPULATORS ============================== */
/**
* Record a value.
* Returns the number of counts in the histogram.
*/
unsigned int tally(int);
/**
* Clear the histogram.
*/
void clear();
/* ============================ ACCESSORS ================================= */
/**
* Get the specified number of bins (which is 2 less than the total number
* of bins).
*/
unsigned int getNoOfBins();
/**
* Get the lowest value for bin 0.
*/
unsigned int getBase();
/**
* Get the size of each bin.
*/
unsigned int getBinSize();
/**
* Get the total count.
*/
unsigned int getCount();
/**
* Get the count in bin i.
* i ranges from -1 to NoOfBins+1.
*/
unsigned int operator[](unsigned int i);
/* ============================ INQUIRY =================================== */
/**
* Get a string containing the formatted values from the bins.
* The caller must free the returned UtlString.
*/
UtlString* show();
/* //////////////////////////// PROTECTED ///////////////////////////////// */
protected:
/* //////////////////////////// PRIVATE /////////////////////////////////// */
private:
// Number of bins.
unsigned int mNoOfBins;
// Lowest value in bin 0.
int mBase;
// Size of each bin:
unsigned int mBinSize;
// Pointer to an array of mNoOfBins int's.
unsigned int* mpBins;
// Total number of counts.
unsigned int mCount;
// Format used to output values.
const char* mOutputFormat;
// Width of output that format will generate.
unsigned int mOutputWidth;
};
/* ============================ INLINE METHODS ============================ */
#endif // _UtlHistogram_h_
|