private void EncodedTable(HNode node, BitSet bitset, Dictionary <byte, BitSet> table) { if (node.IsLeaf) { table.Add(node.Data, bitset); return; } EncodedTable(node.Left, new BitSet(bitset) + 0, table); EncodedTable(node.Right, new BitSet(bitset) + 1, table); }
internal void Pass(HNode node, StringBuilder builder) { if (node == null) { return; } builder.Append("("); Pass(node.Left, builder); builder.Append(node); Pass(node.Right, builder); builder.Append(")"); }
private void Merge(HNode one, HNode other) { var node = new HNode(byte.MinValue, one.Count + other.Count); one.Parent = node; other.Parent = node; node.Left = one; node.Right = other; _nodeList.Add(node); }
private void CreateTree() { while (true) { var hasntParentList = _nodeList.Where(node => !node.HasParent).OrderBy(node => node.Count).ToList(); if (hasntParentList.Count <= 1) { Root = hasntParentList[0]; break; } Merge(hasntParentList[0], hasntParentList[1]); } }