Exemplo n.º 1
0
        public void TestMethodNext()
        {
            var client1 = new Client
            {
                Num      = 100,
                Data     = DateTime.Now,
                Priority = 5
            };

            var client2 = new Client
            {
                Num      = 2,
                Data     = DateTime.Now,
                Priority = 5
            };

            var client3 = new Client
            {
                Num      = 3,
                Data     = DateTime.Now,
                Priority = 5
            };



            var fila = new Queue <Client>();

            var myQueue = new PQueue(fila);

            myQueue.Add(client1);
            myQueue.Add(client3);
            myQueue.Add(client2);

            Assert.AreEqual(100, myQueue.Next());
        }
Exemplo n.º 2
0
        public static void ConstructHuffmanTree(ref HuffmanNode root, PQueue <HuffmanNode> q)
        {
            while (q.Size() > 1)
            {
                HuffmanNode x = q.Peek();
                q.Pop();

                HuffmanNode y = q.Peek();
                q.Pop();

                HuffmanNode f = new HuffmanNode();

                f.Data      = x.Data + y.Data;
                f.Character = '-';

                f.Left  = x;
                f.Right = y;

                root = f;

                q.Add(f);
            }
        }