wu :: forums
« wu :: forums - How to write a generic sort in Java/C#? »

Welcome, Guest. Please Login or Register.
Nov 24th, 2024, 4:23am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   general problem-solving / chatting / whatever
(Moderators: Eigenray, SMQ, william wu, Icarus, ThudnBlunder, Grimbal, towr)
   How to write a generic sort in Java/C#?
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: How to write a generic sort in Java/C#?  (Read 5102 times)
amichail
Senior Riddler
****





   


Posts: 450
How to write a generic sort in Java/C#?  
« on: Jun 10th, 2007, 8:49am »
Quote Quote Modify Modify

I know how but I am curious as to how many people know how to do this.
« Last Edit: Jun 10th, 2007, 8:50am by amichail » IP Logged

DropZap - a new kind of block elimination game
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: How to write a generic sort in Java/C#?  
« Reply #1 on: Jun 10th, 2007, 9:09am »
Quote Quote Modify Modify

I could do it in C++, but I know neither Java nor C# well enough.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
amichail
Senior Riddler
****





   


Posts: 450
Re: How to write a generic sort in Java/C#?  
« Reply #2 on: Jun 10th, 2007, 9:11am »
Quote Quote Modify Modify

The difficulty with doing this doesn't come up in C++.
IP Logged

DropZap - a new kind of block elimination game
amichail
Senior Riddler
****





   


Posts: 450
Re: How to write a generic sort in Java/C#?  
« Reply #3 on: Jun 14th, 2007, 4:56pm »
Quote Quote Modify Modify

So no Java/C# programmers here?
 
You need to use F-bounded polymorphism to solve this problem.
IP Logged

DropZap - a new kind of block elimination game
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: How to write a generic sort in Java/C#?  
« Reply #4 on: Jun 15th, 2007, 12:45am »
Quote Quote Modify 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 Quote Modify 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
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board