Re: How do I use Comparators?
From: Tony Morris (dibblego_at_optusnet.com.au)
Date: 03/11/04
- Next message: Ginger Gooner: "simple i think"
- Previous message: Manfred Rosenboom: "Re: jdk1.1.1 and swing"
- In reply to: SA: "How do I use Comparators?"
- Next in thread: FISH: "Re: How do I use Comparators?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 11 Mar 2004 19:32:48 +1000
"SA" <sarcher@smus.ca> wrote in message
news:835f770a.0403102140.118748fd@posting.google.com...
> I will fully admit that I am doing an assignment BUT I'm not asking
> how to do
> it. I am writing a red-black tree class. The course I'm taking is data
> structures and algorithms using Java. Without telling you my entire
> history,
> I will just say I am taking this course, learning Java as I go.
>
> Anyway, I'm okay with creating the class and understand how the
> methods work. What I don't understand is the parameter we're to use.
> IE. the add method is:
> public boolean add(Comparable data){}
>
> What the heck is a Comparable? The text I have doesn't really have an
> explination and the java docs on sun.com don't really help either in
> this case.
> How do you traverse a tree to insert a node with a Comparable?
>
> IE. using an integer - if (this.value > node.value) {add(value,
> node.right)}
> How do you do that with only the one parameter, the Comparable!?
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html
Have a read - that should be enough to stimulate some thoughts in your own
mind about how you go about using it to implement a tree.
-- Tony Morris (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD) Software Engineer IBM Australia - Tivoli Security Software (2003 VTR1000F)
- Next message: Ginger Gooner: "simple i think"
- Previous message: Manfred Rosenboom: "Re: jdk1.1.1 and swing"
- In reply to: SA: "How do I use Comparators?"
- Next in thread: FISH: "Re: How do I use Comparators?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|