Ejemplo n.º 1
0
 // the private contructor for the class
 private JSONAbleHuffmanNode(HuffmanNode node)
 {
     // symbol is symbol, since a string is normal for json
     symbol = node.Symbol;
     // code is a string instead of an bit array, this is more json friendly
     code = node.Code.Print();
     // right and left tree, is converted recursively
     leftTree  = Parse(node.LeftChildNode);
     rightTree = Parse(node.RightChildNode);
     //lead is just leaf
     isLeaf = node.IsLeaf;
 }
Ejemplo n.º 2
0
 // the private contructor for the class
 // den private contructor for denne klasse
 private JSONAbleHuffmanNode(HuffmanNode node)
 {
     // symbol is symbol, since a string is normal for json
     // symbol er symbol, eftersom at en tekststreng er normalt for json
     symbol = node.Symbol;
     // code is a string instead of an bit array, this is more json friendly
     // code bliver konvertede til en tekststren for at være json venlig
     code = node.Code.Print();
     // right and left tree, is converted recursively
     // højere og venstre node er konverteret rekursivt
     leftTree  = Parse(node.LeftChildNode);
     rightTree = Parse(node.RightChildNode);
     //leaf is just leaf
     //et blad er et blad
     isLeaf = node.IsLeaf;
 }
Ejemplo n.º 3
0
 // This method json serialize the tree
 // json is choosen since it is the easiest for other programs to deserialize
 // and for humans to read
 public string JSONEncode()
 {
     return(JSONAbleHuffmanNode.Parse(Root).Serialize());
 }