I’d like to create various sorting classes (QuickSort, MergeSort, BucketSort…etc).
I have a common Interface (ISort).
This interface has a method:
Collection<T> Sort(Collection<T> list);
Now when im trying to use a class it seems like i have to declare like this:
ISort<char> sort = new QuickSort();
The QuickSort implementation looks like this:
public class QuickSort : ISort<char>
{
public Collection<char> Sort(Collection<char> list)
{
// TODO: implement this.
return null;
}
}
This implementation is what i dont like because the T template is a char.
How can i keep this class generic so that i can use this class to sort an int, float, double, char…etc?
Just like this:
with