MultiResolutionHistogram Class Reference

#include <multi-resolution-histogram.h>

List of all members.


Detailed Description

A data structure for a pyramid of histograms, with a link structure between levels.

A wrapper class around SparseTree. This data structure encapsulates a SparseTree of Bin objects, where a Bin just contains a weight (size) and a count.


Public Member Functions

 MultiResolutionHistogram ()
int size () const
Binbin (LargeIndex index)
 Get a pointer to the bin with the specified index.
Binbin (LargeIndex index, Bin *finger)
 Get a pointer to the bin with specified index.
Binroot ()
 Get a pointer to the root bin.
Bin *const root () const
Binadd_bin (const Bin &new_bin)
 Insert a copy of the given bin into the tree.
Binadd_bin (const Bin &new_bin, Bin *finger)
 Insert a copy of the given bin into the tree.
void remove_bin (Bin *finger)
 Remove a bin, and all of its children, from the pyramid.

Static Public Member Functions

static vector< MultiResolutionHistogram * > ReadFromStream (istream &input_stream)
 Reads all the MultiResolutionHistograms in a stream.
static vector< MultiResolutionHistogram * > ReadFromFile (const char *filename)
 Reads all the MultiResolutionHistograms in a file.
static vector< MultiResolutionHistogram * > ReadSelectionFromStream (istream &input_stream, int start, int selection_size)
 Reads some MultiResolutionHistograms from a stream.
static vector< MultiResolutionHistogram * > ReadSelectionFromFile (const char *filename, int start, int selection_size)
 Reads some MultiResolutionHistograms from a file.
static void WriteToStream (ostream &output_stream, const vector< MultiResolutionHistogram * > &hists)
 Writes all of the MultiResolutionHistograms to a stream.
static void WriteToFile (const char *filename, const vector< MultiResolutionHistogram * > &hists)
 Writes all of the MultiResolutionHistograms to a file.
static MultiResolutionHistogramReadSingleHistogramFromStream (istream &input_stream)
 Reads just one histogram from a stream.
static void IgnoreSingleHistogramFromStream (istream &input_stream)
 Throws out one histogram's worth of data from the stream.
static void WriteSingleHistogramToStream (ostream &output_stream, const MultiResolutionHistogram *h)
 Write just one histogram to a stream.


Constructor & Destructor Documentation

MultiResolutionHistogram (  )  [inline]


Member Function Documentation

int size (  )  const [inline]

Bin * bin ( LargeIndex  index  ) 

Get a pointer to the bin with the specified index.

Returns NULL if the bin is not found.

Bin * bin ( LargeIndex  index,
Bin finger 
)

Get a pointer to the bin with specified index.

Same as GetBin(LargeIndex), but localizes the search to the subtree given by finger. Returns NULL if there is no such Bin in a subtree of <finger>.

Bin* root (  )  [inline]

Get a pointer to the root bin.

Bin* const root (  )  const [inline]

Bin * add_bin ( const Bin new_bin  ) 

Insert a copy of the given bin into the tree.

Returns a pointer to the newly-added bin in the tree. This function completely ignores any parent/child/sibling pointers in <new_bin>.

This function requires the parent bin to exist. It will not create new bins along the way (it will abort if there is no parent bin, i.e., a bin whose index is a prefix of that of <new_bin> and whose index size is exactly 1 less than the new bin's index size. The insertion happens such that the sibling relationships remain sorted by index.

If there is already is a bin with the given index, we add the counts and keep the larger of the two sizes. This applies to the root bin as well.

Bin * add_bin ( const Bin new_bin,
Bin finger 
)

Insert a copy of the given bin into the tree.

Same as add_bin(const Bin&), except it starts the search for the bin at <finger>. A parent to <new_bin> must already exist, and must be present in a sub-branch of <finger> (it may also be <finger>).

void remove_bin ( Bin finger  ) 

Remove a bin, and all of its children, from the pyramid.

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

Reads all the MultiResolutionHistograms in a stream.

File format:

Aborts if input_stream cannot be read.

vector< MultiResolutionHistogram * > ReadFromFile ( const char *  filename  )  [static]

Reads all the MultiResolutionHistograms in a file.

See also:
ReadFromStream

vector< MultiResolutionHistogram * > ReadSelectionFromStream ( istream &  input_stream,
int  start,
int  selection_size 
) [static]

Reads some MultiResolutionHistograms from a stream.

<start> specifies the index of the first histogram to read in the stream of data. If <selection_size> is large enough so that this would want to read past the end of the file, ReadSelectionFromStream will just stop reading. Observe that you will need to adjust indices (i.e., if you choose to read Y histograms starting from index X, then result[0] will be the 6th histogram, as opposed to this[5]).

Aborts if the input_stream cannot be read.

vector< MultiResolutionHistogram * > ReadSelectionFromFile ( const char *  filename,
int  start,
int  selection_size 
) [static]

Reads some MultiResolutionHistograms from a file.

See also:
ReadSelectionFromStream

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

Writes all of the MultiResolutionHistograms to a stream.

Aborts if the stream is bad. See ReadFromStream for the file format.

See also:
ReadFromStream

void WriteToFile ( const char *  filename,
const vector< MultiResolutionHistogram * > &  hists 
) [static]

Writes all of the MultiResolutionHistograms to a file.

See also:
WriteToFile

MultiResolutionHistogram * ReadSingleHistogramFromStream ( istream &  input_stream  )  [static]

Reads just one histogram from a stream.

File format:

void IgnoreSingleHistogramFromStream ( istream &  input_stream  )  [static]

Throws out one histogram's worth of data from the stream.

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

Write just one histogram to a stream.

Aborts if the stream is bad. See ReadSingleHistogramFromStream for the format.

See also:
ReadSingleHistogramFromStream


The documentation for this class was generated from the following files:
Generated on Fri Sep 21 11:39:05 2007 for libpmk2 by  doxygen 1.5.1