There is the following generalized class (it has not been fully implemented yet):
class QuickSorter<Type> { private void Swap(ref Type a, ref Type b) { Type temp = a; a = b; b = temp; } public void Sort(Type[] Array) { //Sort_Recursion(Array); } private void Sort_Recursion(Type[] Array, int L, int R) { /* Type Median = Array[L + (R - L)/2]; // (L + R)/2 = L/2 + R/2 = L - L/2 + R/2 = L + (R - L)/2 ==> Для избежания переполнения int l = L; int r = R; while (l <= r) { while (Array[l] < Median) } */ } public static bool operator >(Type a, Type b) { } public static bool operator <(Type a, Type b) { } } The idea is as follows: I want to implement a quick sort algorithm for given data types (for integer, real, character). I would like to do it in one class. I thought of using a generic class, but in the process of writing code I encountered the problem of comparing variables of a generalized type. Operator overloading for Type not possible in the QuickSorter class. Is there a way to implement overloading of comparison operators for Type in a generic class? Maybe there is another suitable solution for this problem?
IComparableorIComparable<T>- GrundyTypeselect another one, for exampleTThis class (Type) is already in C # - Vadim Prokopchuk