Esempio n. 1
0
        public void TestFailedQueueAt()
        {
            int[] data =
            {
                235,
                21,
                222,
                163,
                522,
                884,
                68,
                17,
                544,
                867,
                444
            };

            var q = new JetPriorityQueue <int>();

            foreach (var i in data)
            {
                q.Add(i);
            }

            var res = new List <int>();

            while (!q.Any())
            {
                res.Add(q.Extract());
            }
            Console.WriteLine(string.Join(",", res.Select(x => x.ToString()).ToArray()) + " : " + res.Count);
        }
Esempio n. 2
0
        public void TestNoComparer()
        {
            var q = new JetPriorityQueue <int>();

            Assert.AreEqual(0, q.Count);
            Assert.True(!q.Any());
            q.Add(5);
            q.Add(3);
            q.Add(4);
            q.Add(1);
            q.Add(2);
            Assert.AreEqual(5, q.Count);
            Assert.False(!q.Any());


            AssertExtract(1, q);
            AssertExtract(2, q);
            AssertExtract(3, q);
            Assert.AreEqual(2, q.Count);

            q.Add(5);
            q.Add(3);
            Assert.AreEqual(4, q.Count);

            AssertExtract(3, q);
            q.Add(1);
            AssertExtract(1, q);


            AssertExtract(4, q);
            AssertExtract(5, q);
            AssertExtract(5, q);

            int x;

            Assert.False(q.TryPeek(out x));
            Assert.False(q.TryExtract(out x));
            Assert.AreEqual(0, q.ExtractOrDefault());
        }