Ejemplo n.º 1
0
        public int ReadValue(BitReader br)
        {
            var node = _root;

            while (!node.IsLeaf)
            {
                node = node.Children[br.ReadBit()];
            }
            return(node.Value);
        }
Ejemplo n.º 2
0
        private void ReadNode(BitReader br, Node node, int valueBitCount)
        {
            var flag = br.ReadBit();

            if (flag != 0)
            {
                node.Children[0] = new Node();
                ReadNode(br, node.Children[0], valueBitCount);

                node.Children[1] = new Node();
                ReadNode(br, node.Children[1], valueBitCount);
            }
            else
            {
                node.Value = br.ReadBits <int>(valueBitCount);
            }
        }