public static void ArraySort(T[] arrayIn, MyArraySortDirection direction, ArraySortMethod sort = ArraySortMethod.QuickSort) { //SortSelection, SortInsertion, SortBuble,SortShells, QuickSort switch (sort) { case ArraySortMethod.QuickSort: ArrayQuickSort(arrayIn, direction); break; case ArraySortMethod.SortSelection: ArraySortSelection(arrayIn, direction); break; case ArraySortMethod.SortInsertion: ArraySortInsertion(arrayIn, direction); break; case ArraySortMethod.SortBuble: ArraySortBuble(arrayIn, direction); break; case ArraySortMethod.SortShells: ArraySortShells(arrayIn, direction); break; default: throw new NotSupportedException(); //break; } }
public void ArraySortMethod_Void(int[] arrayIn, int[] ArrayOut, bool real, MyArraySortDirection direction, ArraySortMethod sortmethod = ArraySortMethod.QuickSort) { MyArray <int> .ArraySort(arrayIn, direction, sortmethod); Assert.AreEqual(real, MyArray <int> .ArrayCompareInt(arrayIn, ArrayOut)); }
public static void Sort_UsingArraySortMethod <T>(this LinkedList <T> list, ArraySortMethod <LinkedListNode <T> > sortMethod, IComparer <T> comparer = null) { LinkedListNode <T>[] arr = list.GetNodes(); IComparer <LinkedListNode <T> > nodeComparer = comparer.GetLinkedListNodeComparer(); // Сортируем массив узлов. sortMethod(arr, nodeComparer); // Восстанавливаем порядок в связном списке на основе массива узлов. list.Reorder_As_In_NodeList(arr); return; }