예제 #1
0
        public void IndexMinHeap_Contains_False(IntHeapItem[] items)
        {
            //Create the heap and add the items except the last one.
            var heap = new IndexMinHeap <IntHeapItem>(items);

            for (var i = 0; i < items.Length - 1; i++)
            {
                heap.Add(i);
            }

            //Check if the last one returns false
            var item = items[items.Length - 1];

            Assert.IsFalse(heap.Contains(items.Length - 1), $"Contains returned true for item {item}");
        }
예제 #2
0
        public void IndexMinHeap_Contains_True(IntHeapItem[] items)
        {
            //Create the heap and add the items.
            var heap = new IndexMinHeap <IntHeapItem>(items);

            for (var i = 0; i < items.Length; i++)
            {
                heap.Add(i);
            }

            //Check if all added items are contained in the heap.
            for (var i = 0; i < items.Length; i++)
            {
                Assert.IsTrue(heap.Contains(i), $"Contains returned false for item {items[i]}");
            }
        }
예제 #3
0
        public void IndexMinHeap_Contains_AddAndRemoveAll(IntHeapItem[] items)
        {
            //Create the heap and add the items except the last one.
            var heap = new IndexMinHeap <IntHeapItem>(items);

            for (var i = 0; i < items.Length; i++)
            {
                heap.Add(i);
            }

            while (heap.Count > 0)
            {
                heap.RemoveFirst();
            }

            for (var i = 0; i < items.Length; i++)
            {
                Assert.IsFalse(heap.Contains(i), $"Contains returned true for index {i}");
            }
        }
 public void Contains()
 {
     _containsMinHeap.Contains(0);
 }