public void RemoveNone() { IntMinHeap heap = new IntMinHeap(); heap.Add(1); bool removeResult = heap.Remove(0); Assert.AreEqual(false, removeResult); }
public void Count(int[] elements, int expectedCount) { IntMinHeap heap = new IntMinHeap(); foreach (int element in elements) { heap.Add(element); } Assert.AreEqual(expectedCount, heap.Count); }
public void GetTopNormal(int[] elements, int expectedTop) { IntMinHeap heap = new IntMinHeap(); foreach (int element in elements) { heap.Add(element); } Assert.AreEqual(expectedTop, heap.GetTop()); }
public void ContainsNormal(int[] elements, int expectedContains, int expectedNotContains) { IntMinHeap heap = new IntMinHeap(); foreach (int element in elements) { heap.Add(element); } Assert.AreEqual(true, heap.Contains(expectedContains)); Assert.AreEqual(false, heap.Contains(expectedNotContains)); }
public void AllGreatThan(int[] elements, int removeNum, bool expectedResult) { IntMinHeap heap = new IntMinHeap(); foreach (int element in elements) { heap.Add(element); } bool checkResult = heap.All(obj => obj > removeNum); Assert.AreEqual(expectedResult, checkResult); }
public void Add(int[] elements, int[] expectedList) { IntMinHeap heap = new IntMinHeap(); foreach (int element in elements) { heap.Add(element); } List <int> numList = heap.GetList(); for (int i = 0; i < numList.Count; i++) { Assert.AreEqual(expectedList[i], numList[i]); } }
public void RemoveAllGreatThan(int[] elements, int removeNum, int[] expectedList) { IntMinHeap heap = new IntMinHeap(); foreach (int element in elements) { heap.Add(element); } heap.RemoveAll(obj => obj > removeNum); List <int> numList = heap.GetList(); for (int i = 0; i < numList.Count; i++) { Assert.AreEqual(expectedList[i], numList[i]); } }
public void Remove(int[] elements, int removeNum, int[] expectedList) { IntMinHeap heap = new IntMinHeap(); foreach (int element in elements) { heap.Add(element); } bool removeResult = heap.Remove(removeNum); List <int> numList = heap.GetList(); for (int i = 0; i < numList.Count; i++) { Assert.AreEqual(expectedList[i], numList[i]); } Assert.AreEqual(true, removeResult); }
/// <summary> /// 查询是否含有某个元素,堆是空的的情况 /// </summary> public void ContainsNone() { IntMinHeap heap = new IntMinHeap(); Assert.AreEqual(false, heap.Contains(0)); }
public void GetTopNoneInt() { IntMinHeap intMinHeap = new IntMinHeap(); Assert.AreEqual(default(int), intMinHeap.GetTop()); }