Histogram Class Reference

#include <histogram.h>

List of all members.


Detailed Description

A sparse representation for a flat (1-D) histogram.

Note that this implementation sorts and consolidates bins lazily, meaning that there can be bins with duplicate indices in the internal structure. However, the public interface behaves as though the internal data is always sorted and consolidated, so there is no need to worry about duplicate bins or unsorted bins when accessing elements using any of the public methods.


Public Member Functions

 Histogram ()
 ~Histogram ()
BinAddBin (const Bin &new_bin)
 Adds a copy of <new_bin> to the histogram.
void SortBins () const
 Sorts and consolidates bins.
int GetNumBins () const
 Gets the total number of bins with unique index.
const BinGetBin (int ii)
 Assuming the Bins are sorted, gets the <ii>th bin in the ordering.
const BinGetBin (const LargeIndex &index)
 Gets the bin with the given index.
const BinGetBin (const LargeIndex &index, int finger)
 Gets the Bin with the given index after the <finger>th Bin.

Static Public Member Functions

static double ComputeIntersection (Histogram *first, Histogram *second)
 Compute the histogram intersection.
static void WriteToStream (ostream &output_stream, const vector< Histogram * > &histograms)
 Write a vector of Histograms to a stream.
static void WriteSingleHistogramToStream (ostream &output_stream, Histogram *h)
 Write a single Histogram to a stream.
static vector< Histogram * > ReadFromStream (istream &input_stream)
 Read a vector of Histograms from a stream.
static HistogramReadSingleHistogramFromStream (istream &input_stream)
 Read a single Histogram from a stream.


Constructor & Destructor Documentation

Histogram (  ) 

~Histogram (  ) 


Member Function Documentation

Bin * AddBin ( const Bin new_bin  ) 

Adds a copy of <new_bin> to the histogram.

By "adding a bin", we mean looking for the Bin in this histogram that has the same index (the LargeIndex identifier) as <new_bin> and increasing the count by that much. It also will set the size of the bin to be the maximum of the two bin sizes. The parent, child, and sibling pointers of <new_bin> are completely ignored.

void SortBins (  )  const

Sorts and consolidates bins.

It is not necessary to call this manually, as all of the sorting and consolidation is done automatically (lazily). However, for performance reasons, you may call this manually.

int GetNumBins (  )  const

Gets the total number of bins with unique index.

const Bin * GetBin ( int  ii  ) 

Assuming the Bins are sorted, gets the <ii>th bin in the ordering.

The Bins are sorted in order of increasing index.

const Bin * GetBin ( const LargeIndex index  ) 

Gets the bin with the given index.

This will return NULL if no such Bin is found.

const Bin * GetBin ( const LargeIndex index,
int  finger 
)

Gets the Bin with the given index after the <finger>th Bin.

This does a linear search for the Bin with the given index, but begins the search from the <finger>th Bin in the sorted list of all Bins.

double ComputeIntersection ( Histogram first,
Histogram second 
) [static]

Compute the histogram intersection.

void WriteToStream ( ostream &  output_stream,
const vector< Histogram * > &  histograms 
) [static]

Write a vector of Histograms to a stream.

The output format is as follows:

void WriteSingleHistogramToStream ( ostream &  output_stream,
Histogram h 
) [static]

Write a single Histogram to a stream.

The output format is as follows:

vector< Histogram * > ReadFromStream ( istream &  input_stream  )  [static]

Read a vector of Histograms from a stream.

This function allocates new memory for the histograms. The caller is responsible for freeing it. For the file format, see WriteToStream.

See also:
WriteToStream

Histogram * ReadSingleHistogramFromStream ( istream &  input_stream  )  [static]

Read a single Histogram from a stream.

This function allocates new memory for the histogram. The caller is responsible for freeing it. For the file format, see ReadFromStream.

See also:
ReadFromStream


The documentation for this class was generated from the following files:
Generated on Wed May 2 11:17:13 2007 for libpmk by  doxygen 1.5.1