示例#1
0
        private void Increment(Node *node)
        {
            Node *lnode;

            if (node == null)
            {
                return;
            }
            if (node->next != null && node->next->weight == node->weight)
            {
                lnode = *node->head;
                if (lnode != node->parent)
                {
                    this.Swap(lnode, node);
                }
                Huffman.Swaplist(lnode, node);
            }
            if (node->prev != null && node->prev->weight == node->weight)
            {
                *node->head = node->prev;
            }
            else
            {
                *node->head = null;
                this.FreePPNode(node->head);
            }
            node->weight++;
            if (node->next != null && node->next->weight == node->weight)
            {
                node->head = node->next->head;
            }
            else
            {
                node->head = this.GetPPNode();
                *node->head = node;
            }
            if (node->parent != null)
            {
                this.Increment(node->parent);
                if (node->prev == node->parent)
                {
                    Huffman.Swaplist(node, node->parent);
                    if (*node->head == node)
                    {
                        *node->head = node->parent;
                    }
                }
            }
        }
示例#2
0
        internal void OutOfBandData(NetAddress address, string data, int length)
        {
            byte [] msg = new byte[this.NetHandler.MaxMessageLength * 2];
            msg[0] = 0xff;
            msg[1] = 0xff;
            msg[2] = 0xff;
            msg[3] = 0xff;
            byte [] dataMsg = Common.Encoding.GetBytes(data);
            dataMsg.CopyTo(msg, 4);
            var mbuf = new Message(msg, msg.Length)
            {
                CurSize = length + 4
            };

            Huffman.Compress(mbuf, 12);
            this.net.SendPacket(mbuf.CurSize, mbuf.Data, address);
        }