Ejemplo n.º 1
0
        private void DecodeCheck4(BitArray bt)
        {
            var valCheck4 = bt.ReadBits(1);

            if (valCheck4 == 0)
            {
                SetAsNode(DecN(bt), 0, null, bt);
                return;
            }

            if (valCheck4 == 1)
            {
                SetAsNode(DecN(bt), null, 0, bt);
                return;
            }

            throw new EventOperationException("Decode Failed (Check4)", this, null);
        }
Ejemplo n.º 2
0
        private void DecodeCheck2(BitArray bt)
        {
            var valCheck2 = bt.ReadBits(2);

            if (valCheck2 == 0)
            {
                Value = 0;
                Left = new Event(0);
                Right = new Event();
                Right.Decode(bt);
                return;
            }

            if (valCheck2 == 1)
            {
                SetAsNode(0, null, 0, bt);
                return;
            }

            if (valCheck2 == 2)
            {
                SetAsNode(0, null, null, bt);
                return;
            }

            if (valCheck2 == 3)
            {
                DecodeCheck3(bt);
                return;
            }

            throw new EventOperationException("Decode Failed (Check2)", this, null);
        }
Ejemplo n.º 3
0
 public char DecN(BitArray bt)
 {
     var n = 0;
     var b = 2;
     while (bt.ReadBits(1) == 1)
     {
         n += (1 << b);
         b++;
     }
     var n2 = bt.ReadBits(b);
     n += n2;
     return (char)n;
 }
Ejemplo n.º 4
0
        public void Decode(BitArray bt)
        {
            var valCheck1 = bt.ReadBits(1);
            if (valCheck1 == 1)
            {
                SetAsLeaf(DecN(bt));
                return;
            }

            if (valCheck1 == 0)
            {
                DecodeCheck2(bt);
                return;
            }

            throw new EventOperationException("Decode Failed", this, null);
        }
Ejemplo n.º 5
0
        // code and decode dos ids
        public void Decode(BitArray bt)
        {
            var val = bt.ReadBits(2);

            if (val == 0)
            {
                SetAsLeaf(bt.ReadBits(1));
                return;
            }

            if (val == 1)
            {
                SetAsNode(null, 0, null, bt);
                return;
            }

            if (val == 2)
            {
                SetAsNode(null, null, 0, bt);
                return;
            }

            if (val == 3)
            {
                SetAsNode(null, null, null, bt);
                return;
            }

            throw new IdOperationException("Decode Failed", this, null);
        }