public void RemoveTest() { var hp = new Heap(8); hp.Add(-2); hp.Add(0); hp.Add(5); hp.Add(5); hp.Add(3); hp.Remove(); string expected = String.Format("[ 0 3 5 5 {0} 0 0 0 ]", int.MaxValue); string actual = hp.ToString(); Assert.AreEqual(actual, expected); }
public static void Sort(int[] a) { var hp = new Heap(a.Length); foreach (int n in a) { hp.Add(n); } for (int i = 0; i < a.Length; i++) { a[i] = hp.Remove(); } }