i'll tell u what ive been doing so far.. Ive got 3 classes, 1) Person (interface extends Comparable) 2) ThePerson (implements Person) 3) PersonList (TreeSet holds collection of Person class)
the Persons will be sorted based on their ID numbers.. so this should be done automatically because im using TreeSet, is this correct?
Now, i want the collection to be slso sorted using another attribue that is "name", iv got a comparator ready to do that, but i cant use
collections.sort(treeSet, comp) <-- because its a Set!!
can some1 please please help me out Hannah
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
Look at the TreeSet constructors. Can you see a way to make a new TreeSet sorted by a comparator using the original for data? [ July 28, 2005: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
H Melua
Ranch Hand
Joined: Jan 04, 2005
Posts: 168
posted
0
aha i c what u mean but i dont wana construct a new 1.... i want the same 1 to be in different order, meaning, i can have the same either order by the ID or by the name... do u get me?
thanks anyway
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
Yup, but I think you're out of luck. Constructing a new one is not that big a deal as long as you kept the variable private so nobody is holding a reference to the old one.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.