Class HNode

java.lang.Object
  extended by HNode

public class HNode
extends java.lang.Object

A binary tree node used for Huffman code trees.


Constructor Summary
HNode()
          Simple constructor - sets all fields to null or 0.
HNode(java.lang.Character c)
          Constructor that sets the character only.
HNode(java.lang.Character c, int freq)
          Constructor that sets the character and frequency.
HNode(java.lang.Character c, int freq, HNode left, HNode right)
          Fully parameterized constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
          Equals predicate considers the Character and frequency only.
 java.lang.Character getChar()
           
 java.lang.String getCode()
           
 int getFrequency()
           
 HNode getLeft()
           
 HNode getRight()
           
 void setChar(java.lang.Character c)
           
 void setCode(java.lang.String code)
           
 void setFrequency(int f)
           
 void setLeft(HNode n)
           
 void setRight(HNode n)
           
 java.lang.String toString()
          String representation of this node.
Format: <HNode: char, frequency, code>
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HNode

public HNode()
Simple constructor - sets all fields to null or 0.


HNode

public HNode(java.lang.Character c)
Constructor that sets the character only.

Parameters:
c - the Character data item

HNode

public HNode(java.lang.Character c,
             int freq)
Constructor that sets the character and frequency.

Parameters:
c - the Character data item
freq - the frequency of occurrence for the character

HNode

public HNode(java.lang.Character c,
             int freq,
             HNode left,
             HNode right)
Fully parameterized constructor.

Parameters:
c - the Character data item
freq - the frequency of occurrence for the character
left - the left child
right - the right child
Method Detail

equals

public boolean equals(java.lang.Object o)
Equals predicate considers the Character and frequency only.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to check for equality
Returns:
true if both the Character and the frequency agree; false otherwise

getChar

public java.lang.Character getChar()

getFrequency

public int getFrequency()

getLeft

public HNode getLeft()

getRight

public HNode getRight()

getCode

public java.lang.String getCode()

setChar

public void setChar(java.lang.Character c)

setFrequency

public void setFrequency(int f)

setLeft

public void setLeft(HNode n)

setRight

public void setRight(HNode n)

setCode

public void setCode(java.lang.String code)

toString

public java.lang.String toString()
String representation of this node.
Format: <HNode: char, frequency, code>

Overrides:
toString in class java.lang.Object
Returns:
the string representation