- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace StringCompresser
- {
- public class Huffman
- {
- //char and its bitarray
- public Dictionary<char, BitArray> HuffmanCode = null;
- //Huffman tree
- public Node[] HuffmanTree = null;
- //huffman tree node
- internal struct Node
- {
- internal char character;
- internal int weight;
- internal int parent;
- internal int lchild;
- internal int rchild;
- }
- public Huffman(char[] charArray, int[] weight)
- {
- if (weight == null || weight.Length == 0
- || charArray == null || charArray.Length == 0
- || weight.Length != charArray.Length)
- return;
- HuffmanCode = new Dictionary<char, BitArray>();
- //build huffman tree
- int totalNodeNum = weight.Length * 2 - 1;
- HuffmanTree = new Node[t
C#实现Huffman编码和解码
最新推荐文章于 2019-08-02 11:59:07 发布