Re: SortedList ?

Discussion in 'Java' started by Thomas Weidenfeller, Jul 1, 2003.

  1. (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
     
    Thomas Weidenfeller, Jul 1, 2003
    #1
    1. Advertising

  2. (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
     
    Thomas Weidenfeller, Jul 3, 2003
    #2
    1. Advertising

  3. Thomas Weidenfeller

    Dale King Guest

    "Gerbrand van Dieijen" <> wrote in message
    news:...
    > On Thu, 3 Jul 2003 11:19:13 +0000 (UTC), Thomas Weidenfeller wrote:
    > > (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/collections/apidocs/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
     
    Dale King, Jul 8, 2003
    #3
  4. Thomas Weidenfeller

    Tim Tyler Guest

    Dale King <> wrote:
    : "Gerbrand van Dieijen" <> 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/collections/apidocs/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/
     
    Tim Tyler, Jul 10, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski

    Problem with SortedList

    Nathan Sokalski, May 30, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,902
    Karl Seguin
    May 30, 2005
  2. Phil Hanna

    Re: SortedList ?

    Phil Hanna, Jul 2, 2003, in forum: Java
    Replies:
    0
    Views:
    841
    Phil Hanna
    Jul 2, 2003
  3. B-rad the Beat Nick

    SortedList: best practices with java 1.5

    B-rad the Beat Nick, Nov 4, 2005, in forum: Java
    Replies:
    5
    Views:
    113,106
    Roedy Green
    Nov 5, 2005
  4. sck10
    Replies:
    4
    Views:
    439
    sck10
    Sep 26, 2006
  5. jc
    Replies:
    1
    Views:
    739
    sloan
    Jul 15, 2008
Loading...

Share This Page