Beispiel #1
0
        public void TryGetValueTest()
        {
            HeapWithIndices <int>         simpleHeap = new HeapWithIndices <int>();
            HeapWithIndices <int, String> heap       = new HeapWithIndices <int, string>();

            for (int i = -10; i <= 10; ++i)
            {
                simpleHeap.Add(i);
            }
            for (int i = -10; i <= 10; ++i)
            {
                heap.Add(i, i.ToString());
            }
            int returnValue = 0;

            simpleHeap.TryGetValue(1, out returnValue);
            Assert.AreEqual(true, simpleHeap.TryGetValue(1, out returnValue));
            Assert.AreEqual(-9, returnValue);
            Assert.AreEqual(false, simpleHeap.TryGetValue(50, out returnValue));
            heap.TryGetValue("-5", out returnValue);
            Assert.AreEqual(true, heap.TryGetValue("-5", out returnValue));
            Assert.AreEqual(-5, returnValue);
            Assert.AreEqual(false, heap.TryGetValue("50", out returnValue));
        }