lab_huffman
Hazardous Huffman Codes
Frequency Class Reference

Frequency: a plain-old-data type representing a character and its frequency. More...

#include "frequency.h"

Public Member Functions

 Frequency (char character, int frequency)
 Constructs a new Frequency object from a given character and its associated frequency in a file. More...
 
 Frequency (int frequency)
 Constructs a new Frequency object from a given frequency count. More...
 
char getCharacter () const
 Getter for the character for this Frequency object. More...
 
int getFrequency () const
 Getter for the frequency for this Frequency object. More...
 
bool operator< (const Frequency &other) const
 Comparison operator for Frequency objects. More...
 

Detailed Description

Frequency: a plain-old-data type representing a character and its frequency.

Used by the HuffmanTree as the data element of the TreeNodes. If a node is an internal node, the character is the null character ('\0').

Author
Chase Geigle
Date
Summer 2012

Constructor & Destructor Documentation

◆ Frequency() [1/2]

Frequency::Frequency ( char  character,
int  frequency 
)

Constructs a new Frequency object from a given character and its associated frequency in a file.

Parameters
characterThe character this Frequency represents.
frequencyThe number of times this character appears in the file.

◆ Frequency() [2/2]

Frequency::Frequency ( int  frequency)

Constructs a new Frequency object from a given frequency count.

Frequencies created this way have the null character ('\0') as their character data (these kinds of Frequency objects are used as the data of internal nodes in the HuffmanTree).

Parameters
frequencyThe number to be stored.

Member Function Documentation

◆ getCharacter()

char Frequency::getCharacter ( ) const

Getter for the character for this Frequency object.

Returns
The character for this Frequency.

◆ getFrequency()

int Frequency::getFrequency ( ) const

Getter for the frequency for this Frequency object.

Returns
The frequency member of this object.

◆ operator<()

bool Frequency::operator< ( const Frequency other) const

Comparison operator for Frequency objects.

Allows for sorting with std::sort.

Parameters
otherThe Frequency object to compare against.
Returns
Whether the current frequency is less than the given frequency (other).

The documentation for this class was generated from the following files: