I am new to c# i have just completed a huffman tree
and now next step is to make it generic
i mean this symbol
should work for every data type
. Since i am c# beginner i need some basic idea to do that.
My huffman tree consists of 3 classes. Class huffman, node and MyClass(which contains the main function) where freq
is the number of times the symbol
repeats they are structured as given below:
namespace final_version_Csharp
{
public Class Huffman
{
public classNode
{
public Node next, left, right;
public int symbol;
public int freq;
}
public Node root;
}
public void huffman_node_processing()
{
//done the addition of two minimum freq here
}
public void GenerateCode(Node parentNode, string code)
{
//done the encoding work here
}
public class MyClass
{
public static void Main(string[] args)
{
Huffman ObjSym = new Huffman(args); //object creation by reading the data fron a file at sole argument
//All other methods are here
ObjSym.huffman_node_processing(); //this for adding the two minimum nodes
ObjSym.GenerateCode(ObjSym.root, ""); //this for encoding
}
}
}
Could some one please help me in making this "symbol" work for all data types like "short","long" etc.