Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: SortedList ?

Reply
Thread Tools

Re: SortedList ?

 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      07-01-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Meir) writes:
> You have got to be kidding: No SortedList in Java2 ?


comp.lang.java.advocacy ist that way --->

> How is it done in Java2 ?


In whatever way you want. E.g. you grap one of the hundreds of
SortedList Java implementations from the net (a Google search for
"SortedList Java" returns 1500+ hits). Or you implement your own. In
your case, a bunch of Lists (one for each priority) in a Map or Set
might do (or might not).

/Thomas
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      07-03-2003
(E-Mail Removed) (Gerbrand van Dieijen) writes:
> Java does have a sorted list, it's the TreeSet in java.util (or other
> Tree...).


The original poster asked for a list that can contain the same key (the
prority) more than once. A set is not suitable for this task.

/Thomas
 
Reply With Quote
 
 
 
 
Dale King
Guest
Posts: n/a
 
      07-08-2003
"Gerbrand van Dieijen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) .uu.nl...
> On Thu, 3 Jul 2003 11:19:13 +0000 (UTC), Thomas Weidenfeller wrote:
> >(E-Mail Removed) (Gerbrand van Dieijen) writes:
> >> Java does have a sorted list, it's the TreeSet in java.util (or other
> >> Tree...).

> >
> >The original poster asked for a list that can contain the same key (the
> >prority) more than once. A set is not suitable for this task.
> >

>
> Ok, I can vaguely remember I read that posting quite a long time
> ago.
> Well shouldn't be too hard to make a bag of a treeset, with a search
> on google this came up at the first page:
> http://jakarta.apache.org/commons/co...cs/org/apache/
> commons/collections/TreeBag.html



The jakarta commons bag may not however be quite right for you. It does not
keep all items added to it. If you add two items that compare as equal it
only keeps 1 of them and simply increments a count of how many of that
object it contains. Unless two items are completely interchangable when they
compare as equal this will not work for you.

Unfortunately, there is a big need for a SortedList and I currently know of
no actual implementations. It is possbile to cobble something together using
a SortedSet of Lists, but no off-the-shelf impelementations.
--
Dale King


 
Reply With Quote
 
Tim Tyler
Guest
Posts: n/a
 
      07-10-2003
Dale King <(E-Mail Removed)> wrote:
: "Gerbrand van Dieijen" <(E-Mail Removed)> wrote in message

:> Well shouldn't be too hard to make a bag of a treeset, with a search
:> on google this came up at the first page:
:> http://jakarta.apache.org/commons/co...cs/org/apache/
:> commons/collections/TreeBag.html

: The jakarta commons bag may not however be quite right for you. It does not
: keep all items added to it. If you add two items that compare as equal it
: only keeps 1 of them and simply increments a count of how many of that
: object it contains. Unless two items are completely interchangable when
: they compare as equal this will not work for you.

It sounds like an attempt at optimisation for the case of many equal
objects.

Commons is O/S. It may well be possible to clone the class, rip out
the check for equality - and proceed from there.
--
__________
|im |yler http://timtyler.org/ (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting files from Datalist? IO.Directory ? SortedList? jc ASP .Net 1 07-15-2008 09:51 PM
Retrieve SortedList from Class (App_Code) sck10 ASP .Net 4 09-26-2006 03:19 PM
SortedList: best practices with java 1.5 B-rad the Beat Nick Java 5 11-05-2005 08:50 AM
Problem with SortedList Nathan Sokalski ASP .Net 1 05-30-2005 01:20 PM
Re: SortedList ? Phil Hanna Java 0 07-02-2003 02:50 AM



Advertisments