Author |
Topic: How to write a generic sort in Java/C#? (Read 5102 times) |
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: How to write a generic sort in Java/C#?
« Reply #1 on: Jun 10th, 2007, 9:09am » |
Quote Modify
|
I could do it in C++, but I know neither Java nor C# well enough.
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: How to write a generic sort in Java/C#?
« Reply #4 on: Jun 15th, 2007, 12:45am » |
Quote Modify
|
on Jun 14th, 2007, 4:56pm, amichail wrote:You need to use F-bounded polymorphism to solve this problem. |
| How is that different from the solution in C++ ?
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
amichail
Senior Riddler
Posts: 450
|
|
Re: How to write a generic sort in Java/C#?
« Reply #5 on: Jun 15th, 2007, 4:56am » |
Quote Modify
|
on Jun 15th, 2007, 12:45am, towr wrote: How is that different from the solution in C++ ? |
| In Java/C#, you need to specify a constraint on the sorts of types allowed in the array to sort. For example, you might say that elements of the array must implement the Comparable interface. But it's more complicated than that. These sorts of constraints allow you to compile generic code independently of its clients. On a related note, if you would like to see state of the art language design, try Scala.
|
« Last Edit: Jun 15th, 2007, 5:03am by amichail » |
IP Logged |
DropZap - a new kind of block elimination game
|
|
|
|