示例#1
0
        public void TransferToExtendedTest()
        {
            var q1 = new PriorityQueueOptimized <CPersonWithIndex>(sm_peopleWithIndex);
            var q2 = new PriorityQueueExtended <CPersonWithIndex>(q1);

            var arr1 = q1.ToArray();
            var arr2 = q2.ToArray();

            Assert.AreEqual(arr1.Length, arr2.Length, "Array lengths aren't equal");

            for (var i = 0; i < arr1.Length; i++)
            {
                Assert.AreEqual(arr1[i], arr2[i], "The objects are not equal at index " + i);
            }
        }
示例#2
0
        public void TransferToDifferentPQTest()
        {
            var q1 = new PriorityQueueExtended <CPersonWithIndex>(sm_peopleWithIndex);
            var q2 = new PriorityQueueOptimized <CPersonWithIndex>(q1, LambdaComparer <CPersonWithIndex> .FromFunc((_l, _r) => _r.Age - _l.Age));

            var arr1 = q1.ToArray();
            var arr2 = q2.ToArray();

            Assert.AreEqual(arr1.Length, arr2.Length, "Array lengths aren't equal");

            for (var i = 0; i < arr1.Length; i++)
            {
                var j = arr1.Length - i - 1;
                Assert.AreEqual(arr1[i], arr2[j], "The objects are not equal at index " + i + " / " + j);
            }
        }