示例#1
0
        public void Remove()
        {
            // Create a new priority queue.
            ConcurrentPriorityQueue <int> queue = new ConcurrentPriorityQueue <int>();

            // Create and store a few elements.
            PriorityValuePair <int> elem1 = new PriorityValuePair <int>(1.0, 2);
            PriorityValuePair <int> elem2 = new PriorityValuePair <int>(2.0, 4);
            PriorityValuePair <int> elem3 = new PriorityValuePair <int>(3.0, 6);

            // Expect Remove() to return false for an empty queue.
            Assert.That(queue.Remove(elem1), Is.False);

            // Enqueue 2 of the elements into the heap.
            queue.Enqueue(elem2);
            queue.Enqueue(elem3);

            // Expect Remove() to return false for elem1, indicating the element was removed
            // (since it doesn't belong to the heap and can't be found). This tests the if-else
            // case for when the provided element isn't found in the heap.
            Assert.That(queue.Remove(elem1), Is.False);

            // Expect Remove() to return true for elem2, indicating the element was removed
            // (since it belongs to the heap and can be found). This tests the if-else case for
            // when Count is 2 or greater.
            Assert.That(queue.Remove(elem2), Is.True);

            // Expect Remove() to return true for elem3, indicating the element was removed
            // (since it belongs to the heap and can be found). This tests the if-else case for
            // when Count equals 1.
            Assert.That(queue.Remove(elem3), Is.True);
        }
示例#2
0
 public int Remove(PokeTradeDetail <TPoke> detail) => Queue.Remove(detail);