private static void Main(string[] args) { MaxComparer <int> comparer = new MaxComparer <int>(); List <int> list = new List <int> { 8, 15, 11, 6, 9, 7, 8, 1, 3, 5 }; BinaryHeap <int> kucha = new BinaryHeap <int>(list, comparer); Console.WriteLine(kucha.GetMaxOrMin()); Console.ReadKey(); }
public void Test_SortWthInterface_KeySum() { double[][] a = new double[3][]; a[0] = new double[2] { 2, 2 }; a[1] = new double[2] { 3, 3 }; a[2] = new double[3] { 1, 1, 1 }; IComparer<Double[]> comparer = new MaxComparer(); SortClass.SortWithInterfaces(a, comparer); CollectionAssert.AreEqual(a[0], new double[3] { 1, 1, 1 }); CollectionAssert.AreEqual(a[1], new double[2] { 2, 2 }); CollectionAssert.AreEqual(a[2], new double[2] { 3, 3 }); }
public void Sort_MaxCompareAscDelegate_SuccessfulTests() { var comparer = new MaxComparer(); for (int i = 0; i < _maxSourceData.Length; i++) { Sorter.Sort(_maxSourceData[i], comparer.Compare); if (!MatrixAreEquals(_maxSourceData[i], _resultMax[i])) { Assert.Fail($"Arrays of {i} index don't equal! "); } } }
public void Sort_MaxCompareAsc_SuccessfulTests() { IComparer <int[]> compare = new MaxComparer(); for (int i = 0; i < _maxSourceData.Length; i++) { Task1.AnotherSorter.Sort(_maxSourceData[i], compare); if (!MatrixAreEquals(_maxSourceData[i], _resultMax[i])) { Assert.Fail($"Arrays of {i} index don't equal! "); } } }
public void Sort_MaxCompareDec_SuccessfulTests() { IComparer <int[]> compare = new MaxComparer(false); foreach (var subarray in _resultMax) { Array.Reverse(subarray); } for (int i = 0; i < _maxSourceData.Length; i++) { Sorter.Sort(_maxSourceData[i], compare); if (!MatrixAreEquals(_maxSourceData[i], _resultMax[i])) { Assert.Fail($"Arrays of {i} index don't equal! "); } } }