示例#1
0
        public void Encode()
        {
            data = new MyData();
            Element element;

            for (int i = 0; i < input_s.Length; i++)
            {
                element = new Element(1, input_s[i]);
                data.Add(element);
            }
            data.Sort();
            Tree mytree = new Tree(data);

            mytree.Grow();
            WriteToFile();
        }
示例#2
0
        public void Grow()
        {
            while (array.Length != 1)
            {
                Element min1   = array[array.Length - 1];
                Element min2   = array[array.Length - 2];
                Element parent = new Element(1, '~');
                Array.Resize(ref array, array.Length - 1);

                min1.Parent = parent;
                min2.Parent = parent;
                parent.Node(min2, min1);
                array[array.Length - 1] = parent;
                data.SetArray(array);
                data.Sort();
            }
        }