Asking inverse() function for List and ArrayList

Discussion in 'Java' started by =?iso-8859-1?B?bW9vcJk=?=, Dec 12, 2005.

  1. Hi,
    I think to have a function to inverse a list is quite natural to be
    embedded into the standard JSE library, how do you think about that?
     
    =?iso-8859-1?B?bW9vcJk=?=, Dec 12, 2005
    #1
    1. Advertisements

  2. =?iso-8859-1?B?bW9vcJk=?=

    IchBin Guest

    If I understand you question.. look at this link..

    http://javaalmanac.com/egs/java.util/coll_SortList.html

    --


    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
     
    IchBin, Dec 12, 2005
    #2
    1. Advertisements

  3. =?iso-8859-1?B?bW9vcJk=?=

    Roedy Green Guest

    what do you mean my that, sort a list in reverse order? make the first
    last and the last first etc. Both of those are quite easy to do.
     
    Roedy Green, Dec 12, 2005
    #3
  4. =?iso-8859-1?B?bW9vcJk=?=

    Rhino Guest

    It depends on what you mean by inversing a list.

    If you mean that a given list contains 0, 1, 2, 3, and 4 and you want the
    inverse function to give you the other digits, i.e. 5 through 9 inclusive,
    that might be reasonable, as long as you are willing to ignore that some
    cultures have their own number systems that don't use the base 10 digits.

    You'd have similar issues if you wanted to inverse letters. If a given list
    contains 'A', 'B', and 'C' what inverse would you want to see? If you are an
    English-speaker, you'd presumably want 'D' through 'Z' inclusive. But other
    cultures that used other languages, alphabets, and scripts would want
    something quite different.

    At the very least, your inverse function would need to be very
    culturally-sensitive if it was to work beyond the confines of English and
    base 10 arithmetic.

    Rhino
     
    Rhino, Dec 12, 2005
    #5
  5. Given a list {0, 1, 2, 3, 4} I suppose the OP means a function that
    returns {4, 3, 2, 1, 0}. Keep it simple :)

    Francesco
     
    Francesco Devittori, Dec 12, 2005
    #6
  6. =?iso-8859-1?B?bW9vcJk=?=

    Rhino Guest

    You could be right but I think the key to the analysis of this problem is to
    understand what the original poster meant by 'inverse', not just assume that
    it was something simple. It's entirely possible that he/she _did_ want the
    inverse of {0,1,2,3,4} to be {5,6,7,8,9} or maybe something else altogether,
    not {4,3,2,1,0}. We can't know until we clarify what he/she meant. And until
    you understand the question, you can't give a good answer.

    Rhino
     
    Rhino, Dec 12, 2005
    #7
  7. You are right, but what you say is not the inverse of a list but the
    inverse of each object in the list, which is something different.

    list.inverse() vs. for(e: list) e.inverse();

    (not even sure one could inverse an int anyway)

    Francesco
     
    Francesco Devittori, Dec 12, 2005
    #8
  8. =?iso-8859-1?B?bW9vcJk=?=

    IchBin Guest

    Shame the OP does not return a comment to the intention.

    --


    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
     
    IchBin, Dec 12, 2005
    #9
  9. =?iso-8859-1?B?bW9vcJk=?=

    Oliver Wong Guest

    When someone says the "inverse of an integer", they probably mean the
    modular inverse. That means you need to have some sort of implied modulo m,
    and the inverse (b^-1) of an integer b is such that b (b^-1) = 1 (mod m).

    If m is not prime, then not every integer will have an inverse.

    But for what it's worth, I had assumed the OP wanted the list returned
    in reverse order, like Francesco initially did.

    - Oliver
     
    Oliver Wong, Dec 12, 2005
    #10
  10. I am so so so sorry for my innocent of Java Collections that I dont
    know the existent of Collections.reverse(), exactly what IchBin replied
    next to my post is the answer I am looking for. I dont know my ask for
    help attracts your attentions so much, I am sorry for my confused
    question. so I am very much thanks about all of you for your kindness
    reactions, I feel so warm for your helps, thanks a lot!! Thanks!
     
    =?iso-8859-1?B?bW9vcJk=?=, Dec 13, 2005
    #11
  11. =?iso-8859-1?B?bW9vcJk=?=

    andreaz Guest

    andreaz, Dec 13, 2005
    #12
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.